feat(FN-4924): apply cache ttl hydration across dashboard hooks

Fusion-Task-Id: FN-4924
Fusion-Task-Lineage: a5f882e1-8348-4f9d-89be-15994adc148c
This commit is contained in:
Fusion (runfusion.ai)
2026-05-17 10:55:53 -07:00
committed by gsxdsm
parent 7ad3449c8f
commit cf12704885
13 changed files with 121 additions and 37 deletions

View File

@@ -10,7 +10,7 @@ import {
type ProjectInfoWithSource,
type ProjectNodeAvailability,
} from "../api";
import { SWR_CACHE_KEYS, clearCache, readCache, writeCache } from "../utils/swrCache";
import { SWR_CACHE_KEYS, SWR_DEFAULT_MAX_AGE_MS, clearCache, readCache, writeCache } from "../utils/swrCache";
export interface UseProjectsResult {
/** List of all registered projects (local + remote) */
@@ -77,7 +77,7 @@ function normalizeProjects(projects: ProjectInfoWithSource[]): ProjectInfoWithSo
*/
export function useProjects(): UseProjectsResult {
const [projects, setProjects] = useState<ProjectInfoWithSource[]>(() => {
const cached = readCache<ProjectInfoWithSource[]>(SWR_CACHE_KEYS.PROJECTS);
const cached = readCache<ProjectInfoWithSource[]>(SWR_CACHE_KEYS.PROJECTS, { maxAgeMs: SWR_DEFAULT_MAX_AGE_MS });
if (!Array.isArray(cached)) {
return [];
}