mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-31 03:49:11 +00:00
fix: account for pending timers
This commit is contained in:
committed by
Carlos Valente
parent
147e5f5a27
commit
ee1753ef29
@@ -1850,4 +1850,44 @@ describe('getTimerPhase()', () => {
|
|||||||
const phase = getTimerPhase(state);
|
const phase = getTimerPhase(state);
|
||||||
expect(phase).toBe(TimerPhase.Default);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -385,6 +385,11 @@ export function getTimerPhase(state: RuntimeState): TimerPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const current = state.timer.current;
|
const current = state.timer.current;
|
||||||
|
|
||||||
|
if (current === null || state.eventNow === null) {
|
||||||
|
return TimerPhase.Pending;
|
||||||
|
}
|
||||||
|
|
||||||
if (current < 0) {
|
if (current < 0) {
|
||||||
return TimerPhase.Negative;
|
return TimerPhase.Negative;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export enum TimerPhase {
|
|||||||
Warning = 'warning',
|
Warning = 'warning',
|
||||||
Danger = 'danger',
|
Danger = 'danger',
|
||||||
Negative = 'negative',
|
Negative = 'negative',
|
||||||
|
Pending = 'pending', // used for waiting to roll
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TimerState = {
|
export type TimerState = {
|
||||||
|
|||||||
Reference in New Issue
Block a user