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

fix: server overrides user's locale/appearance #2771

Merged
merged 2 commits into from Jan 16, 2024

Conversation

harveyghq
Copy link
Contributor

Close #2767.

Locale usage sequence: storage locale > user locale > server's default locale. (same for appearance)

Copy link
Collaborator

@boojack boojack left a comment

Choose a reason for hiding this comment

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

LGTM otherwise

web/src/App.tsx Outdated Show resolved Hide resolved
@harveyghq harveyghq force-pushed the fix/server-overrides-user-locale branch from ce5b52a to 4c70bfa Compare January 16, 2024 10:15
@boojack boojack merged commit 15e6542 into usememos:main Jan 16, 2024
5 checks passed
@harveyghq
Copy link
Contributor Author

Test: user can change user locale in Preferences / specify a new locale when logging in. Storage locale overrides user locale.

test1

Note: currently when a user doesn't set locale, the default user setting en and follow system will override server's setting.
Maybe in the future, we need to use server's setting locale/appearance as default user setting. (see here)

@boojack
Copy link
Collaborator

boojack commented Jan 16, 2024

So the order here should be user setting -> storage -> system setting.

@boojack
Copy link
Collaborator

boojack commented Jan 16, 2024

FYI, fixed in 9ffd827

@harveyghq
Copy link
Contributor Author

harveyghq commented Jan 16, 2024

But what if a user specifies a new locale in login/sign up page? It will be overriden when the user is logged in. @boojack

I presume that users can configure additional preferences during the login process; otherwise, those buttons would lose their purpose and require users to reconfigure locale/appearance in the settings later.

test

@harveyghq
Copy link
Contributor Author

harveyghq commented Jan 16, 2024

Some scenarios to consider:

  • A fresh start: A new user signs up and specifies their preferences on the sign-up page. These preferences should remain unchanged later.
  • A signed-up user opens a new browser and logs in without modifying their preference settings on the login page. In this case, the server's default preferences should change to match the user's previously stored preferences.
  • A signed-up user specifies new preferences during login, or if they haven't cleared their browser's storage (with last used preferences). These preferences should not be replaced by their preferences stored in the database, and may even require an update to the user's preferences.

So considering above scenarios, I considered using storage > user > server a reasonable one. By giving priority to local storage preferences and only updating them when users specify their preferences during login or when defaults need to be replaced after login, this method ensures that the user's most recent choices take precedence.

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.

0.18.2 Language set invalid
2 participants