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
Implement persistent dark mode setting and & Implement persistent dark mode setting #2423
base: main
Are you sure you want to change the base?
Conversation
Changed the mechanism for retrieving the user's selected language. Instead of directly setting the language in the i18n configuration, the updated code now fetches the short name of the language based on the savedLanguage value. This short name is then used to persistently set the user's preferred language across platform sessions, ensuring that the language preference is retained even after a refresh. This update addresses the issue where the platform would revert to English on every refresh, disregarding the user's previously selected language preference.
dded functionality to save the dark mode state in the user's local storage. This ensures that the dark mode preference is maintained across different sessions and page reloads. When the user selects dark mode, this preference is now stored locally, and upon returning to the platform, the dark mode setting is automatically applied based on the saved preference. This change enhances user experience by maintaining consistent appearance settings, eliminating the need to re-enable dark mode on each visit.
Thanks a lot! We will check that tomorrow :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR
Here some changes to do before merging :)
frontend/lib/context/UserSettingsProvider/User-settings.provider.tsx
Outdated
Show resolved
Hide resolved
frontend/lib/context/UserSettingsProvider/User-settings.provider.tsx
Outdated
Show resolved
Hide resolved
frontend/app/user/components/LanguageSelect/hooks/useLanguageHook.ts
Outdated
Show resolved
Hide resolved
frontend/app/user/components/LanguageSelect/hooks/useLanguageHook.ts
Outdated
Show resolved
Hide resolved
@ellipsis-dev Please review this pr |
OK! Reviewing this PR... Responding to this comment by @StanGirard. For more information about Ellipsis, check the documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me!
- Reviewed the entire pull request up to bb45566
- Looked at
46
lines of code in2
files - Took 1 minute and 55 seconds to review
More info
- Skipped
0
files when reviewing. - Skipped posting
2
additional comments because they didn't meet confidence threshold of50%
.
1. /frontend/lib/context/UserSettingsProvider/User-settings.provider.tsx:24
:
- Assessed confidence :
80%
- Grade:
30%
- Comment:
Consider providing a more sensible default value forisDarkMode
whenwindow
is undefined. Currently, it defaults totrue
which might not always be the desired behavior. - Reasoning:
In the UserSettingsProvider, the initial state of isDarkMode is set based on the value stored in localStorage. However, if the window object is undefined (which might be the case during server-side rendering), the initial state is always set to true. This might not be the desired behavior, as it assumes that the user always prefers dark mode when server-side rendering is used. It would be better to have a more sensible default, or to delay the rendering of the component until the client-side scripts have loaded and the actual preference can be determined.
2. /frontend/app/user/components/LanguageSelect/hooks/useLanguageHook.ts:62
:
- Assessed confidence :
100%
- Grade:
0%
- Comment:
Consider adding a check to ensure that the saved language exists in the list of available languages. If the saved language is not in the list, you might want to set the current language to a default value. - Reasoning:
In the useLanguageHook, the saved language is retrieved from localStorage and then used to set the current language. However, there is no check to ensure that the saved language actually exists in the list of available languages. If the saved language is not in the list, the current language will be set to undefined, and an error might occur when trying to access the shortName property of undefined.
Workflow ID: wflow_8ci9kLA9Uc4YR5dX
Not what you expected? You can customize the content of the reviews using rules. Learn more here.
@StanGirard Just fixed all the problems |
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Checklist before requesting a review
Please delete options that are not relevant.
Screenshots (if appropriate):
Summary:
This PR updates the
useLanguageHook
andUserSettingsProvider
functions to use theshortName
of the selected language when changing the language and to retrieve and store the dark mode setting from and to local storage, respectively.Key points:
useLanguageHook
in/frontend/app/user/components/LanguageSelect/hooks/useLanguageHook.ts
to useshortName
of selected language when changing language.UserSettingsProvider
in/frontend/lib/context/UserSettingsProvider/User-settings.provider.tsx
to retrieve dark mode setting from local storage.change
event onmediaQueryList
inUserSettingsProvider
to store updated dark mode setting in local storage.Generated with ❤️ by ellipsis.dev