diff --git a/src/screens/ProjectsScreen.tsx b/src/screens/ProjectsScreen.tsx index 54f8a38..e3cae6a 100644 --- a/src/screens/ProjectsScreen.tsx +++ b/src/screens/ProjectsScreen.tsx @@ -12,7 +12,7 @@ import { import * as api from '../api/endpoints'; import { Project } from '../api/types'; import { useSession } from '../auth/session'; -import { getProjects, saveProjectList, setActiveProjectId } from '../db/repositories'; +import { getProjects, saveProjectList, saveTemplates, setActiveProjectId } from '../db/repositories'; import { isOnline } from '../net/connectivity'; import { runSync } from '../sync/engine'; import { RootStackParamList } from '../navigation/types'; @@ -38,6 +38,15 @@ export function ProjectsScreen({ navigation }: Props) { if (await isOnline()) { const list = normalize(await api.listProjects()); await saveProjectList(list); + // Prefetch del catálogo global de plantillas: así quedan SIEMPRE en + // local y se puede inspeccionar offline aunque el proyecto no se haya + // abierto todavía. No bloquea la lista si /templates falla. + try { + const { templates } = await api.getTemplates(); + await saveTemplates(templates); + } catch (e) { + console.warn('No se pudieron prefetchar las plantillas:', e); + } } setProjects(await getProjects()); } catch (e) {