mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-18 21:54:09 +00:00
trigger doRoll if clock is less than startAt
This commit is contained in:
@@ -339,7 +339,7 @@ export class TimerService {
|
|||||||
this.timer.expectedFinish >= this.timer.startedAt
|
this.timer.expectedFinish >= this.timer.startedAt
|
||||||
? this.timer.expectedFinish
|
? this.timer.expectedFinish
|
||||||
: this.timer.expectedFinish + dayInMs,
|
: this.timer.expectedFinish + dayInMs,
|
||||||
|
_startAt: this.timer.startedAt,
|
||||||
clock: this.timer.clock,
|
clock: this.timer.clock,
|
||||||
secondaryTimer: this.timer.secondaryTimer,
|
secondaryTimer: this.timer.secondaryTimer,
|
||||||
secondaryTarget: this.secondaryTarget,
|
secondaryTarget: this.secondaryTarget,
|
||||||
|
|||||||
@@ -703,4 +703,24 @@ describe('typical scenarios', () => {
|
|||||||
|
|
||||||
expect(updateRoll(timers)).toStrictEqual(expected);
|
expect(updateRoll(timers)).toStrictEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('rolls backwards', () => {
|
||||||
|
const timers = {
|
||||||
|
selectedEventId: '1',
|
||||||
|
current: 11,
|
||||||
|
_startAt: 10,
|
||||||
|
_finishAt: 15,
|
||||||
|
clock: 9,
|
||||||
|
secondaryTimer: null,
|
||||||
|
secondaryTarget: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
const expected = {
|
||||||
|
updatedTimer: timers._finishAt - timers.clock,
|
||||||
|
updatedSecondaryTimer: null,
|
||||||
|
doRollLoad: true,
|
||||||
|
isFinished: false,
|
||||||
|
};
|
||||||
|
expect(updateRoll(timers)).toStrictEqual(expected);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ type CurrentTimers = {
|
|||||||
selectedEventId: string | null;
|
selectedEventId: string | null;
|
||||||
current: number | null;
|
current: number | null;
|
||||||
_finishAt: number | null;
|
_finishAt: number | null;
|
||||||
|
_startAt: number | null;
|
||||||
clock: number | null;
|
clock: number | null;
|
||||||
secondaryTimer: number | null;
|
secondaryTimer: number | null;
|
||||||
secondaryTarget: number | null;
|
secondaryTarget: number | null;
|
||||||
@@ -164,7 +165,7 @@ type CurrentTimers = {
|
|||||||
* @returns {object} object with selection variables
|
* @returns {object} object with selection variables
|
||||||
*/
|
*/
|
||||||
export const updateRoll = (currentTimers: CurrentTimers) => {
|
export const updateRoll = (currentTimers: CurrentTimers) => {
|
||||||
const { selectedEventId, current, _finishAt, clock, secondaryTimer, secondaryTarget } = currentTimers;
|
const { selectedEventId, current, _finishAt, _startAt, clock, secondaryTimer, secondaryTarget } = currentTimers;
|
||||||
|
|
||||||
// timers
|
// timers
|
||||||
let updatedTimer = current;
|
let updatedTimer = current;
|
||||||
@@ -182,10 +183,14 @@ export const updateRoll = (currentTimers: CurrentTimers) => {
|
|||||||
updatedTimer -= dayInMs;
|
updatedTimer -= dayInMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(Math.floor(_startAt / 1000), Math.floor(clock / 1000));
|
||||||
|
|
||||||
if (updatedTimer < 0) {
|
if (updatedTimer < 0) {
|
||||||
isPrimaryFinished = true;
|
isPrimaryFinished = true;
|
||||||
// we need a new event
|
// we need a new event
|
||||||
doRollLoad = true;
|
doRollLoad = true;
|
||||||
|
} else if (clock < _startAt) {
|
||||||
|
doRollLoad = true;
|
||||||
}
|
}
|
||||||
} else if (secondaryTimer >= 0) {
|
} else if (secondaryTimer >= 0) {
|
||||||
// if secondaryTimer is running we are in waiting to roll
|
// if secondaryTimer is running we are in waiting to roll
|
||||||
|
|||||||
Reference in New Issue
Block a user