trigger doRoll if clock is less than startAt

This commit is contained in:
arc-alex
2023-11-20 17:44:39 +01:00
parent afa62a6e38
commit facce4f096
3 changed files with 27 additions and 2 deletions
+6 -1
View File
@@ -153,6 +153,7 @@ type CurrentTimers = {
selectedEventId: string | null;
current: number | null;
_finishAt: number | null;
_startAt: number | null;
clock: number | null;
secondaryTimer: number | null;
secondaryTarget: number | null;
@@ -164,7 +165,7 @@ type CurrentTimers = {
* @returns {object} object with selection variables
*/
export const updateRoll = (currentTimers: CurrentTimers) => {
const { selectedEventId, current, _finishAt, clock, secondaryTimer, secondaryTarget } = currentTimers;
const { selectedEventId, current, _finishAt, _startAt, clock, secondaryTimer, secondaryTarget } = currentTimers;
// timers
let updatedTimer = current;
@@ -182,10 +183,14 @@ export const updateRoll = (currentTimers: CurrentTimers) => {
updatedTimer -= dayInMs;
}
console.log(Math.floor(_startAt / 1000), Math.floor(clock / 1000));
if (updatedTimer < 0) {
isPrimaryFinished = true;
// we need a new event
doRollLoad = true;
} else if (clock < _startAt) {
doRollLoad = true;
}
} else if (secondaryTimer >= 0) {
// if secondaryTimer is running we are in waiting to roll