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

Implement persistent dark mode setting and & Implement persistent dark mode setting #2423

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

elazarnaaman
Copy link

@elazarnaaman elazarnaaman commented Apr 11, 2024

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.

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented hard-to-understand areas
  • I have ideally added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

Screenshots (if appropriate):


Ellipsis 🚀 This PR description was created by Ellipsis for commit bb45566.

Summary:

This PR updates the useLanguageHook and UserSettingsProvider functions to use the shortName 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:

  • Updated useLanguageHook in /frontend/app/user/components/LanguageSelect/hooks/useLanguageHook.ts to use shortName of selected language when changing language.
  • Updated UserSettingsProvider in /frontend/lib/context/UserSettingsProvider/User-settings.provider.tsx to retrieve dark mode setting from local storage.
  • Updated listener for change event on mediaQueryList in UserSettingsProvider to store updated dark mode setting in local storage.

Generated with ❤️ by ellipsis.dev

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.
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. area: frontend Related to frontend functionality or under the /frontend directory labels Apr 11, 2024
@StanGirard
Copy link
Collaborator

Thanks a lot! We will check that tomorrow :)

@StanGirard StanGirard requested a review from Zewed April 11, 2024 16:49
Copy link
Collaborator

@Zewed Zewed left a 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 :)

@StanGirard
Copy link
Collaborator

@ellipsis-dev Please review this pr

Copy link
Contributor

ellipsis-dev bot commented Apr 12, 2024

OK! Reviewing this PR...


Responding to this comment by @StanGirard. For more information about Ellipsis, check the documentation.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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 in 2 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 of 50%.
1. /frontend/lib/context/UserSettingsProvider/User-settings.provider.tsx:24:
  • Assessed confidence : 80%
  • Grade: 30%
  • Comment:
    Consider providing a more sensible default value for isDarkMode when window is undefined. Currently, it defaults to true 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.

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 20, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Apr 20, 2024
@elazarnaaman
Copy link
Author

@StanGirard Just fixed all the problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: frontend Related to frontend functionality or under the /frontend directory size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants