@gadmin2n/schematics 0.0.119 → 0.0.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useUserPageAccess.ts
CHANGED
|
@@ -82,23 +82,27 @@ function writeCache(key: string, value: unknown): void {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
// In dev mode, skip sessionStorage cache so menu changes after seed are
|
|
86
|
+
// visible immediately without clearing browser storage manually.
|
|
87
|
+
const IS_DEV = import.meta.env.DEV;
|
|
88
|
+
|
|
85
89
|
export const useUserPageAccess = (): UseUserPageAccessResult => {
|
|
86
90
|
const [isIdentityLoading, setIsIdentityLoading] = useState(true);
|
|
87
91
|
|
|
88
92
|
// Role names — initialise from cache so first render is non-empty
|
|
89
|
-
const [roleNames, setRoleNames] = useState<string[]>(
|
|
90
|
-
|
|
93
|
+
const [roleNames, setRoleNames] = useState<string[]>(() =>
|
|
94
|
+
IS_DEV ? [] : (readCache<string[]>(RoleCacheKey) ?? []),
|
|
91
95
|
);
|
|
92
96
|
|
|
93
97
|
// Data states — initialise from cache for instant first render
|
|
94
98
|
const [rolesData, setRolesData] = useState<Role[] | null>(() =>
|
|
95
|
-
readCache<Role[]>(RolesDataCacheKey),
|
|
99
|
+
IS_DEV ? null : readCache<Role[]>(RolesDataCacheKey),
|
|
96
100
|
);
|
|
97
101
|
const [rolePagesData, setRolePagesData] = useState<RolePage[] | null>(() =>
|
|
98
|
-
readCache<RolePage[]>(RolePagesCacheKey),
|
|
102
|
+
IS_DEV ? null : readCache<RolePage[]>(RolePagesCacheKey),
|
|
99
103
|
);
|
|
100
104
|
const [pagesData, setPagesData] = useState<Page[] | null>(() =>
|
|
101
|
-
readCache<Page[]>(PagesCacheKey),
|
|
105
|
+
IS_DEV ? null : readCache<Page[]>(PagesCacheKey),
|
|
102
106
|
);
|
|
103
107
|
|
|
104
108
|
// Track previous roles to detect changes
|
|
@@ -312,7 +316,8 @@ export const useUserPageAccess = (): UseUserPageAccessResult => {
|
|
|
312
316
|
// Calculate loading state
|
|
313
317
|
// If we have cached data, isLoading is false even while background-refreshing
|
|
314
318
|
const hasCache = useMemo(
|
|
315
|
-
() =>
|
|
319
|
+
() =>
|
|
320
|
+
!IS_DEV && !!(readCache(PagesCacheKey) && readCache(RolePagesCacheKey)),
|
|
316
321
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
317
322
|
[],
|
|
318
323
|
);
|