feat(timer): playing sound on time end

This commit is contained in:
Carlos Valente
2024-10-07 20:31:04 +02:00
committed by Carlos Valente
parent 265b167600
commit 4c08ca2908
10 changed files with 216 additions and 0 deletions
@@ -189,3 +189,18 @@ export function getCardData(
nextSecondary,
};
}
/**
* Whether the end of timer sound should play for a given phase transition
* We only sound the transition into overtime from a phase that was already counting,
* which keeps a client that connects or reloads mid-overtime silent
*/
export function shouldPlayEndSound(previousPhase: TimerPhase | null, phase: TimerPhase): boolean {
if (phase !== TimerPhase.Overtime) {
return false;
}
return (
previousPhase === TimerPhase.Default || previousPhase === TimerPhase.Warning || previousPhase === TimerPhase.Danger
);
}