diff --git a/apps/server/src/services/__tests__/timerUtils.test.ts b/apps/server/src/services/__tests__/timerUtils.test.ts index 50fb7ab59..aa3bb7a66 100644 --- a/apps/server/src/services/__tests__/timerUtils.test.ts +++ b/apps/server/src/services/__tests__/timerUtils.test.ts @@ -1850,4 +1850,44 @@ describe('getTimerPhase()', () => { const phase = getTimerPhase(state); expect(phase).toBe(TimerPhase.Default); }); + + it('#1042 identifies waiting to roll', () => { + const state = { + clock: 55691050, + eventNow: null, + publicEventNow: null, + eventNext: null, + publicEventNext: null, + runtime: { + selectedEventIndex: null, + numEvents: 1, + offset: null, + plannedStart: 55860000, + plannedEnd: 55880000, + actualStart: null, + expectedEnd: null, + }, + timer: { + addedTime: 0, + current: null, + duration: null, + elapsed: 0, + expectedFinish: null, + finishedAt: null, + phase: 'none', + playback: 'roll', + secondaryTimer: 168950, + startedAt: null, + }, + _timer: { + forceFinish: null, + totalDelay: 0, + pausedAt: null, + secondaryTarget: 55860000, + }, + } as RuntimeState; + + const phase = getTimerPhase(state); + expect(phase).toBe(TimerPhase.Pending); + }); }); diff --git a/apps/server/src/services/timerUtils.ts b/apps/server/src/services/timerUtils.ts index aadb46d21..487b36e17 100644 --- a/apps/server/src/services/timerUtils.ts +++ b/apps/server/src/services/timerUtils.ts @@ -385,6 +385,11 @@ export function getTimerPhase(state: RuntimeState): TimerPhase { } const current = state.timer.current; + + if (current === null || state.eventNow === null) { + return TimerPhase.Pending; + } + if (current < 0) { return TimerPhase.Negative; } diff --git a/packages/types/src/definitions/runtime/TimerState.type.ts b/packages/types/src/definitions/runtime/TimerState.type.ts index b56aa098c..59f98769f 100644 --- a/packages/types/src/definitions/runtime/TimerState.type.ts +++ b/packages/types/src/definitions/runtime/TimerState.type.ts @@ -7,6 +7,7 @@ export enum TimerPhase { Warning = 'warning', Danger = 'danger', Negative = 'negative', + Pending = 'pending', // used for waiting to roll } export type TimerState = {