[WEB-4956] fix: onboarding redirect with cache busting and code refactor (#7822)

* fix: resolve onboarding completion redirect with cache-busting

* chore: code refactor
This commit is contained in:
Anmol Singh Bhatia 2025-09-17 19:50:37 +05:30 committed by GitHub
parent 877c117c37
commit 696635dbb0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 5 deletions

View file

@ -85,8 +85,9 @@ export class UserService extends APIService {
}); });
} }
async currentUserSettings(): Promise<IUserSettings> { async currentUserSettings(bustCache: boolean = false): Promise<IUserSettings> {
return this.get("/api/users/me/settings/") const url = bustCache ? `/api/users/me/settings/?t=${Date.now()}` : "/api/users/me/settings/";
return this.get(url)
.then((response) => response?.data) .then((response) => response?.data)
.catch((error) => { .catch((error) => {
throw error?.response; throw error?.response;

View file

@ -172,6 +172,14 @@ export class ProfileStore implements IUserProfileStore {
runInAction(() => { runInAction(() => {
this.mutateUserProfile({ ...dataToUpdate, is_onboarded: true }); 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) { } catch (error) {
runInAction(() => { runInAction(() => {
this.error = { this.error = {

View file

@ -23,7 +23,7 @@ export interface IUserSettingsStore {
sidebarCollapsed: boolean; sidebarCollapsed: boolean;
isScrolled: boolean; isScrolled: boolean;
// actions // actions
fetchCurrentUserSettings: () => Promise<IUserSettings | undefined>; fetchCurrentUserSettings: (bustCache?: boolean) => Promise<IUserSettings | undefined>;
toggleLocalDB: (workspaceSlug: string | undefined, projectId: string | undefined) => Promise<void>; toggleLocalDB: (workspaceSlug: string | undefined, projectId: string | undefined) => Promise<void>;
toggleSidebar: (collapsed?: boolean) => void; toggleSidebar: (collapsed?: boolean) => void;
toggleIsScrolled: (isScrolled?: boolean) => void; toggleIsScrolled: (isScrolled?: boolean) => void;
@ -113,13 +113,13 @@ export class UserSettingsStore implements IUserSettingsStore {
* @description fetches user profile information * @description fetches user profile information
* @returns {Promise<IUserSettings | undefined>} * @returns {Promise<IUserSettings | undefined>}
*/ */
fetchCurrentUserSettings = async () => { fetchCurrentUserSettings = async (bustCache: boolean = false) => {
try { try {
runInAction(() => { runInAction(() => {
this.isLoading = true; this.isLoading = true;
this.error = undefined; this.error = undefined;
}); });
const userSettings = await this.userService.currentUserSettings(); const userSettings = await this.userService.currentUserSettings(bustCache);
runInAction(() => { runInAction(() => {
this.isLoading = false; this.isLoading = false;
this.data = userSettings; this.data = userSettings;