diff --git a/apps/web/core/services/user.service.ts b/apps/web/core/services/user.service.ts index 585c88b6c..379ac9521 100644 --- a/apps/web/core/services/user.service.ts +++ b/apps/web/core/services/user.service.ts @@ -85,8 +85,9 @@ export class UserService extends APIService { }); } - async currentUserSettings(): Promise { - return this.get("/api/users/me/settings/") + async currentUserSettings(bustCache: boolean = false): Promise { + const url = bustCache ? `/api/users/me/settings/?t=${Date.now()}` : "/api/users/me/settings/"; + return this.get(url) .then((response) => response?.data) .catch((error) => { throw error?.response; diff --git a/apps/web/core/store/user/profile.store.ts b/apps/web/core/store/user/profile.store.ts index df9a9efb9..9604dda9b 100644 --- a/apps/web/core/store/user/profile.store.ts +++ b/apps/web/core/store/user/profile.store.ts @@ -172,6 +172,14 @@ export class ProfileStore implements IUserProfileStore { runInAction(() => { this.mutateUserProfile({ ...dataToUpdate, is_onboarded: true }); }); + + // Also fetch from backend to ensure consistency and refresh user settings with cache-busting + Promise.all([ + this.fetchUserProfile(), + this.store.user.userSettings.fetchCurrentUserSettings(true), // Cache-busting enabled + ]).catch((error) => { + console.error("Background sync failed:", error); + }); } catch (error) { runInAction(() => { this.error = { diff --git a/apps/web/core/store/user/settings.store.ts b/apps/web/core/store/user/settings.store.ts index 348e7a9df..6f85ce1eb 100644 --- a/apps/web/core/store/user/settings.store.ts +++ b/apps/web/core/store/user/settings.store.ts @@ -23,7 +23,7 @@ export interface IUserSettingsStore { sidebarCollapsed: boolean; isScrolled: boolean; // actions - fetchCurrentUserSettings: () => Promise; + fetchCurrentUserSettings: (bustCache?: boolean) => Promise; toggleLocalDB: (workspaceSlug: string | undefined, projectId: string | undefined) => Promise; toggleSidebar: (collapsed?: boolean) => void; toggleIsScrolled: (isScrolled?: boolean) => void; @@ -113,13 +113,13 @@ export class UserSettingsStore implements IUserSettingsStore { * @description fetches user profile information * @returns {Promise} */ - fetchCurrentUserSettings = async () => { + fetchCurrentUserSettings = async (bustCache: boolean = false) => { try { runInAction(() => { this.isLoading = true; this.error = undefined; }); - const userSettings = await this.userService.currentUserSettings(); + const userSettings = await this.userService.currentUserSettings(bustCache); runInAction(() => { this.isLoading = false; this.data = userSettings;