Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add possibility to listen on displayOptions changes #142

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

matystl
Copy link
Contributor

@matystl matystl commented Dec 5, 2019

Problem: currently as user i can set displayOptions when voyager is initialized. But there is no option to listen on changes when user change this settings. That means it is really hard to implement persistence of settings in query prams or localstorage.

Solution: Add to props callback function that will be called on every user settings change. Also i added to demo folder how it can be persisted in query params.

Possibly fixes issues: #107 #103 #12

Small problem: When voyager is loaded and provided rootType doesn't exist it will break instead of not honoring that setting. It has almost nothing with this PR but as soon as user has rootType in query params it happens more often and it is not quite straightforward that he should just delete query params to fix problem and make everithing working. But as library(builded version) no setting in query params is implemented and is up to users to implemented so it could probably be fixed later.

@matystl matystl changed the title Add possibility to listen on displayOptions changes [Feature] Add possibility to listen on displayOptions changes Dec 5, 2019
demo/index.tsx Outdated
this.displayOptions[key] = JSON.parse(value);
} catch (_) {
console.log(
'Not expected value for key "',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use a template string here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

demo/index.tsx Outdated
},
body: JSON.stringify({ query: introspectionQuery }),
...(withCredentials === 'true' ? { credentials: 'include', mode: 'cors' } : {}),
}).then(response => response.json());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please run prettier on these files as a separate PR?
It would way easier to review this PR and will keep commit history clean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created PR #143 and will rebase this it after it will be merged

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebased

@matystl matystl force-pushed the update-on-display-options-change branch 3 times, most recently from ac97d33 to 9cb44d0 Compare December 5, 2019 20:50
@matystl matystl force-pushed the update-on-display-options-change branch from 9cb44d0 to 2c7db46 Compare December 5, 2019 20:51
@matystl
Copy link
Contributor Author

matystl commented Jan 6, 2020

@IvanGoncharov reminder for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants