From 52a9da18f257773a22d985eb280f843521e89dc4 Mon Sep 17 00:00:00 2001 From: litruv Date: Tue, 3 Nov 2026 04:46:26 +1100 Subject: [PATCH] Gate the splash on rooms only and hold only the remaining animation time. --- src/app/pages/client/ClientRoot.tsx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/app/pages/client/ClientRoot.tsx b/src/app/pages/client/ClientRoot.tsx index da0a50b6..bf4b83b6 100644 --- a/src/app/pages/client/ClientRoot.tsx +++ b/src/app/pages/client/ClientRoot.tsx @@ -167,14 +167,21 @@ export function ClientRoot({ children }: ClientRootProps) { // first sync) can not leave the splash up forever. const splashDeadline = useRef(undefined); - const scheduleHide = useCallback((reason?: string) => { - if (splashHoldTimer.current !== undefined) return; + // The splash particles animate for 450ms with up to 640ms of stagger. Hold only + // for whatever is left of that, so a load that already took longer swaps at once. + const splashShownAt = useRef(performance.now()); + const splashHidden = useRef(false); - if (reason) console.log(`[ClientRoot] Hiding splash: ${reason}`); + const scheduleHide = useCallback((reason?: string) => { + if (splashHidden.current) return; + + const hold = Math.max(0, 1100 - (performance.now() - splashShownAt.current)); + if (reason) console.log(`[ClientRoot] Hiding splash: ${reason} (hold ${Math.round(hold)}ms)`); + splashHidden.current = true; splashHoldTimer.current = window.setTimeout(() => { splashHoldTimer.current = undefined; setLoading(false); - }, 1500); + }, hold); }, []); // The UI renders chats from the room-list atoms, which are filled by @@ -182,10 +189,9 @@ export function ClientRoot({ children }: ClientRootProps) { // so the first paint after the splash already contains the chats. const roomsAtom = useAtomValue(allRoomsAtom); const directsAtom = useAtomValue(mDirectAtom); - const chatsReady = - roomsAtom.length > 0 && - directsAtom.size > 0 && - roomsAtom.some((roomId) => directsAtom.has(roomId)); + // An account with no direct chats can never satisfy a gate that requires one, so it + // always waits for the deadline. Gate on the rooms only. + const chatsReady = roomsAtom.length > 0; const tryHide = useCallback( (reason: string): boolean => { @@ -285,12 +291,10 @@ export function ClientRoot({ children }: ClientRootProps) { }, 10000); } - const poll = window.setInterval(check, 400); mx.on(ClientEvent.Room, check); mx.on(ClientEvent.AccountData, check); return () => { - window.clearInterval(poll); mx.removeListener(ClientEvent.Room, check); mx.removeListener(ClientEvent.AccountData, check); };