From 5a3dc157046e77c1d0a8bdabeedb73a358f7a6d8 Mon Sep 17 00:00:00 2001 From: byGalax Date: Thu, 14 May 2026 06:24:05 +0200 Subject: [PATCH] chore(mobile): extract ENDED_STATE_LINGER_MS constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- apps/mobile/lib/callContext.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/mobile/lib/callContext.tsx b/apps/mobile/lib/callContext.tsx index a4eba04..7a3b22b 100644 --- a/apps/mobile/lib/callContext.tsx +++ b/apps/mobile/lib/callContext.tsx @@ -62,6 +62,12 @@ function randomCallId(): string { 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 }) { const { user } = useAuth(); const myUserId = user?.id ?? null; @@ -353,13 +359,13 @@ export function CallProvider({ children }: { children: React.ReactNode }) { } }, [state]); - // Drift `ended` back to `idle` after a short pause so the UI can show - // a brief status pill ("Anruf abgelehnt") before snapping back. + // Drift `ended` back to `idle` after the linger window so the UI can + // show a brief status pill before snapping back. useEffect(() => { if (state.kind !== 'ended') return; const t = setTimeout(() => { setState({ kind: 'idle' }); - }, 2500); + }, ENDED_STATE_LINGER_MS); return () => clearTimeout(t); }, [state]);