Unverified Commit 9f8921d3 authored by varsnotwars's avatar varsnotwars Committed by GitHub

fix: preference not being saved (#4980)

Signed-off-by: 's avatarvarsnotwars <varsnotwars@protonmail.com>
Co-authored-by: 's avatarJohnny <yourselfhosted@gmail.com>
parent 1f1add1a
...@@ -280,6 +280,10 @@ const userStore = (() => { ...@@ -280,6 +280,10 @@ const userStore = (() => {
}; };
})(); })();
// TODO: refactor initialUserStore as it has temporal coupling
// need to make it more clear that the order of the body is important
// or it leads to false positives
// See: https://github.com/usememos/memos/issues/4978
export const initialUserStore = async () => { export const initialUserStore = async () => {
try { try {
const { user: currentUser } = await authServiceClient.getCurrentSession({}); const { user: currentUser } = await authServiceClient.getCurrentSession({});
...@@ -293,9 +297,6 @@ export const initialUserStore = async () => { ...@@ -293,9 +297,6 @@ export const initialUserStore = async () => {
return; return;
} }
// Fetch all user settings
await userStore.fetchUserSettings();
userStore.state.setPartial({ userStore.state.setPartial({
currentUser: currentUser.name, currentUser: currentUser.name,
userMapByName: { userMapByName: {
...@@ -303,6 +304,10 @@ export const initialUserStore = async () => { ...@@ -303,6 +304,10 @@ export const initialUserStore = async () => {
}, },
}); });
// must be called after user is set in store
await userStore.fetchUserSettings();
// must be run after fetchUserSettings is called.
// Apply general settings to workspace if available // Apply general settings to workspace if available
const generalSetting = userStore.state.userGeneralSetting; const generalSetting = userStore.state.userGeneralSetting;
if (generalSetting) { if (generalSetting) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment