fix: workspace spinner — use profile (not null user) and add 8s context timeouts
singlePlayerPage was using useUser().user which is always null (no setter in UserContext). This caused the redirect effect to always fire, making the workspace completely inaccessible. Fixed by destructuring profile as user, which IS properly set from the Supabase profiles query. Also added 8s timeout to NeoUserContext.switchContext call to match the NeoInstituteContext timeout fix, preventing infinite spinner if the navigation API call hangs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ab1f8111f6
commit
679653c118
@ -226,13 +226,19 @@ export const NeoUserProvider: React.FC<{ children: ReactNode }> = ({ children })
|
|||||||
// Initialize user node in profile context
|
// Initialize user node in profile context
|
||||||
logger.debug('neo-user-context', '🔄 Starting context initialization');
|
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<void>((_, reject) =>
|
||||||
|
setTimeout(() => reject(new Error('switchContext timed out after 8000ms')), 8000)
|
||||||
|
)
|
||||||
try {
|
try {
|
||||||
await navigationStore.switchContext({
|
await Promise.race([
|
||||||
|
navigationStore.switchContext({
|
||||||
main: 'profile',
|
main: 'profile',
|
||||||
base: 'profile',
|
base: 'profile',
|
||||||
extended: 'overview'
|
extended: 'overview'
|
||||||
}, userDb, profile.school_db_name);
|
}, userDb, profile.school_db_name),
|
||||||
|
switchTimeout
|
||||||
|
]);
|
||||||
|
|
||||||
const userNavigationNode = navigationStore.context.node;
|
const userNavigationNode = navigationStore.context.node;
|
||||||
if (userNavigationNode?.id && userNavigationNode?.data) {
|
if (userNavigationNode?.id && userNavigationNode?.data) {
|
||||||
|
|||||||
@ -45,7 +45,7 @@ interface LoadingState {
|
|||||||
|
|
||||||
export default function SinglePlayerPage() {
|
export default function SinglePlayerPage() {
|
||||||
// Context hooks with initialization states
|
// Context hooks with initialization states
|
||||||
const { user, loading: userLoading } = useUser();
|
const { profile: user, loading: userLoading } = useUser();
|
||||||
const {
|
const {
|
||||||
tldrawPreferences,
|
tldrawPreferences,
|
||||||
initializePreferences,
|
initializePreferences,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user