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

feat: save NMRium preferences by workspace #1393

Merged
merged 6 commits into from Mar 3, 2022
Merged

Conversation

hamed-musallam
Copy link
Member

No description provided.

@netlify
Copy link

netlify bot commented Mar 1, 2022

✔️ Deploy Preview for nmrium ready!

🔨 Explore the source changes: 4603504

🔍 Inspect the deploy log: https://app.netlify.com/sites/nmrium/deploys/622091ea54b31a000802b632

😎 Browse the preview: https://deploy-preview-1393--nmrium.netlify.app/

@hamed-musallam
Copy link
Member Author

@lpatiny
Can you test it

@lpatiny
Copy link
Member

lpatiny commented Mar 2, 2022

The functionality is ok for me.

@targos Here is the context of this PR. Currently on www.nmrium.org the exercises show all the options of NMRium which is not ok. The reason for this is that preferences are stored in local storage and when we reload the preferences it ignores the one specific to exercises (ie the exercise 'mode').

However there is also a nice feature in NMRium that is the 'mode'. You can define a preset of settings that will configure NMRium in the mode you like.

With this PR the goal is that settings are related to the mode. In the future this would allow a user to create its own mode in the general preferences depending if he prefers to make an assignment of 2D or just a prediction.

This PR also allows to hide the 'general settings' so that in the exercise mode there is no way for the student to add more features.

Finally this mode approach will allow to have our NMRium version specific to prediction as we discussed.

@targos could you review the implementation ?

@targos
Copy link
Member

targos commented Mar 2, 2022

I see issues with the implementation (mostly that the state update functions are not pure, since they interact with localstorage), but that's not new from this PR, so it looks ok.

Comment on lines 8 to 10
return useMemo(() => {
return preferences.formatting.panels[key] || null;
}, [key, preferences.formatting.panels]);
Copy link
Member

Choose a reason for hiding this comment

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

nothing takes time or risks creating a new object here, the useMemo is counterproductive (comparing the dependencies is not costless)

@hamed-musallam hamed-musallam changed the title chore: save NMRium preferences by mode feat: save NMRium preferences by mode Mar 2, 2022
@lpatiny lpatiny changed the title feat: save NMRium preferences by mode feat: save NMRium preferences by workspace Mar 3, 2022
change name from mode to workspace
move hideExperimentalFeatures object under display>general object
increment local storage version number
@hamed-musallam hamed-musallam merged commit 83ddbc5 into master Mar 3, 2022
@hamed-musallam hamed-musallam deleted the preferencesByMode branch March 3, 2022 11:09
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.

None yet

3 participants