- Remove NeoUserProvider + NeoInstituteProvider from App.tsx startup chain - Strip user_db_name/school_db_name from CCUser; add school_id (Phase B wires it to Supabase) - Remove DatabaseNameService from AuthContext and UserContext - Remove provisionUser() call from login path; API endpoint preserved for Phase B decision - Simplify UserContext.resolveProfile: fast-path JWT metadata then background Supabase fetch - Replace user.user_db_name reads in singlePlayerPage + snapshotService with null-safe guards - Add useDeviceContext hook (desktop/tablet/phone/iwb, persists to localStorage) App now loads to dashboard without any Neo4j dependency at startup. Canvas opens to blank TLDraw state; Phase B rebuilds navigation on Supabase. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { useState, useEffect } from 'react';
|
|
|
|
export type DeviceType = 'desktop' | 'tablet' | 'phone' | 'iwb';
|
|
|
|
function detectDeviceType(): DeviceType {
|
|
const width = window.innerWidth;
|
|
const touchPoints = navigator.maxTouchPoints ?? 0;
|
|
const hasTouch = touchPoints > 0 || 'ontouchstart' in window;
|
|
|
|
if (width >= 1280 && !hasTouch) return 'desktop';
|
|
if (width >= 768 && hasTouch) return 'tablet';
|
|
if (width < 768) return 'phone';
|
|
return 'desktop';
|
|
}
|
|
|
|
const STORAGE_KEY = 'cc_device_type';
|
|
|
|
export function useDeviceContext() {
|
|
const [deviceType, setDeviceTypeState] = useState<DeviceType>(() => {
|
|
const stored = localStorage.getItem(STORAGE_KEY) as DeviceType | null;
|
|
if (stored && ['desktop', 'tablet', 'phone', 'iwb'].includes(stored)) return stored;
|
|
return detectDeviceType();
|
|
});
|
|
|
|
useEffect(() => {
|
|
localStorage.setItem(STORAGE_KEY, deviceType);
|
|
}, [deviceType]);
|
|
|
|
const setDeviceType = (type: DeviceType) => {
|
|
setDeviceTypeState(type);
|
|
};
|
|
|
|
const isTouch = deviceType === 'tablet' || deviceType === 'phone';
|
|
const isMobileLayout = deviceType === 'phone';
|
|
|
|
return { deviceType, setDeviceType, isTouch, isMobileLayout };
|
|
}
|