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:
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user