diff --git a/src/contexts/NeoUserContext.tsx b/src/contexts/NeoUserContext.tsx index 2c92d19..ffb6ce5 100644 --- a/src/contexts/NeoUserContext.tsx +++ b/src/contexts/NeoUserContext.tsx @@ -226,13 +226,19 @@ export const NeoUserProvider: React.FC<{ children: ReactNode }> = ({ children }) // Initialize user node in profile context logger.debug('neo-user-context', '🔄 Starting context initialization'); - // Initialize user node + // Initialize user node — race against 8s timeout so spinner never hangs + const switchTimeout = new Promise((_, reject) => + setTimeout(() => reject(new Error('switchContext timed out after 8000ms')), 8000) + ) try { - await navigationStore.switchContext({ - main: 'profile', - base: 'profile', - extended: 'overview' - }, userDb, profile.school_db_name); + await Promise.race([ + navigationStore.switchContext({ + main: 'profile', + base: 'profile', + extended: 'overview' + }, userDb, profile.school_db_name), + switchTimeout + ]); const userNavigationNode = navigationStore.context.node; if (userNavigationNode?.id && userNavigationNode?.data) { diff --git a/src/pages/tldraw/singlePlayerPage.tsx b/src/pages/tldraw/singlePlayerPage.tsx index 989de8d..569269a 100644 --- a/src/pages/tldraw/singlePlayerPage.tsx +++ b/src/pages/tldraw/singlePlayerPage.tsx @@ -45,7 +45,7 @@ interface LoadingState { export default function SinglePlayerPage() { // Context hooks with initialization states - const { user, loading: userLoading } = useUser(); + const { profile: user, loading: userLoading } = useUser(); const { tldrawPreferences, initializePreferences,