mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-14 22:17:36 +00:00
fix(ui): restore tenant selection state from localStorage on reload (#693)
The Zustand persist migration excluded tenantSelected from the partialize whitelist, causing it to reset to false on page reload. This created a redirect loop: require-auth saw the intermediate state (connected + tenants loaded + tenantSelected=false) and redirected to /select-tenant before the WS auto-select callback could fire. Restore the original localStorage-derived initialization so tenantSelected is true immediately on rehydration when a tenant scope was previously saved. Closes #692
This commit is contained in:
1 parent
aa5158d4a2
commit
3d9c71a8a2
1 file changed
+2
-1
@@ -1,5 +1,6 @@
|
||||
import { create } from "zustand";
|
||||
import { persist } from "zustand/middleware";
|
||||
import { LOCAL_STORAGE_KEYS } from "@/lib/constants";
|
||||
import { clearSetupSkippedState } from "@/lib/setup-skip";
|
||||
import type { TenantMembership } from "@/types/tenant";
|
||||
|
||||
@@ -43,7 +44,7 @@ export const useAuthStore = create<AuthState>()(
|
||||
tenantSlug: "",
|
||||
isOwner: false,
|
||||
availableTenants: [],
|
||||
tenantSelected: false,
|
||||
tenantSelected: !!localStorage.getItem(LOCAL_STORAGE_KEYS.TENANT_ID),
|
||||
|
||||
setCredentials: (token, userId) => {
|
||||
set({ token, userId });
|
||||
|
||||
Reference in new issue
Block a user