mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-14 03:43:50 +00:00
move skip logic to timerUtils
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { MaybeNumber, TimerType } from 'ontime-types';
|
||||
import { dayInMs } from 'ontime-utils';
|
||||
import { config } from '../config/config.js';
|
||||
|
||||
/**
|
||||
* Calculates expected finish time of a running timer
|
||||
@@ -64,3 +65,15 @@ export function getCurrent(
|
||||
}
|
||||
return startedAt + duration + addedTime + pausedTime - clock;
|
||||
}
|
||||
|
||||
export function skipedOutOfEvent(previousTime: number, clock: number, startedAt: number, finishAt): boolean {
|
||||
const skipTime = previousTime - clock;
|
||||
const hasSkipped = Math.abs(skipTime) > config.timeSkipLimit;
|
||||
if (hasSkipped) {
|
||||
if (clock > finishAt || clock < startedAt) {
|
||||
return true;
|
||||
}
|
||||
// otherwise we just skipped within the event
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user