chore(mobile): extract ENDED_STATE_LINGER_MS constant

The 2500ms timer that drifts CallState from `ended` back to `idle` was
an inline magic number. Promote to a module-level constant with a
comment explaining why the value isn't arbitrary — picked from the
post-Phase-3 quality review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
byGalax
2026-05-14 06:24:05 +02:00
parent 10d3e91bbb
commit 5a3dc15704
+9 -3
View File
@@ -62,6 +62,12 @@ function randomCallId(): string {
return 'call-' + Math.random().toString(36).slice(2, 10) + '-' + Date.now().toString(36); return 'call-' + Math.random().toString(36).slice(2, 10) + '-' + Date.now().toString(36);
} }
// Time the call state lingers in `ended` so the UI can render a transient
// status pill ("Anruf abgelehnt", "Anruf beendet") before snapping back
// to idle. Keep this comfortably above the user's reaction time but short
// enough that returning to a chat feels snappy.
const ENDED_STATE_LINGER_MS = 2500;
export function CallProvider({ children }: { children: React.ReactNode }) { export function CallProvider({ children }: { children: React.ReactNode }) {
const { user } = useAuth(); const { user } = useAuth();
const myUserId = user?.id ?? null; const myUserId = user?.id ?? null;
@@ -353,13 +359,13 @@ export function CallProvider({ children }: { children: React.ReactNode }) {
} }
}, [state]); }, [state]);
// Drift `ended` back to `idle` after a short pause so the UI can show // Drift `ended` back to `idle` after the linger window so the UI can
// a brief status pill ("Anruf abgelehnt") before snapping back. // show a brief status pill before snapping back.
useEffect(() => { useEffect(() => {
if (state.kind !== 'ended') return; if (state.kind !== 'ended') return;
const t = setTimeout(() => { const t = setTimeout(() => {
setState({ kind: 'idle' }); setState({ kind: 'idle' });
}, 2500); }, ENDED_STATE_LINGER_MS);
return () => clearTimeout(t); return () => clearTimeout(t);
}, [state]); }, [state]);