From f0c398070021b12abe987af7ae9ee1089fd4eb6e Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 12 Jun 2023 16:18:01 +0200 Subject: [PATCH] fix(user): fix flickering of default settings --- src/stores/auth.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/stores/auth.ts b/src/stores/auth.ts index f6de60557..d2744a9ce 100644 --- a/src/stores/auth.ts +++ b/src/stores/auth.ts @@ -69,12 +69,12 @@ export const useAuthStore = defineStore('auth', () => { isLoadingGeneralSettings.value = isLoading } - function setUser(newUser: IUser | null) { + function setUser(newUser: IUser | null, saveSettings: boolean = true) { info.value = newUser if (newUser !== null) { reloadAvatar() - if (newUser.settings) { + if (saveSettings && newUser.settings) { loadSettings(newUser.settings) } @@ -101,7 +101,7 @@ export const useAuthStore = defineStore('auth', () => { ...newSettings.frontendSettings, } }) - console.log('settings from auth store', {...settings.value.frontendSettings}) + // console.log('settings from auth store', {...settings.value.frontendSettings}) } function setAuthenticated(newAuthenticated: boolean) { @@ -233,7 +233,8 @@ export const useAuthStore = defineStore('auth', () => { const info = new UserModel(JSON.parse(atob(base64))) const ts = Math.round((new Date()).getTime() / MILLISECONDS_A_SECOND) isAuthenticated = info.exp >= ts - setUser(info) + // Settings should only be loaded from the api request, not via the jwt + setUser(info, false) if (isAuthenticated) { await refreshUserInfo()