mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-07 15:29:10 +00:00
clock "is" a count up timer
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { millisToSeconds } from 'ontime-utils';
|
import { millisToSeconds } from 'ontime-utils';
|
||||||
import { MaybeNumber } from 'ontime-types';
|
import { MaybeNumber, TimerType } from 'ontime-types';
|
||||||
|
|
||||||
import { timerConfig } from '../../setup/config.js';
|
import { timerConfig } from '../../setup/config.js';
|
||||||
|
|
||||||
@@ -13,8 +13,8 @@ export function getShouldClockUpdate(previousUpdate: number, now: number): boole
|
|||||||
if (shouldForceUpdate) {
|
if (shouldForceUpdate) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const isClockSecondAhead = millisToSeconds(now) !== millisToSeconds(previousUpdate + timerConfig.triggerAhead);
|
const newSeconds = millisToSeconds(now, TimerType.CountUp) !== millisToSeconds(previousUpdate, TimerType.CountUp);
|
||||||
return isClockSecondAhead;
|
return newSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,6 +39,5 @@ export function getShouldTimerUpdate(previousValue: MaybeNumber, currentValue: M
|
|||||||
export function getForceUpdate(previousUpdate: number, now: number): boolean {
|
export function getForceUpdate(previousUpdate: number, now: number): boolean {
|
||||||
const isClockBehind = now < previousUpdate;
|
const isClockBehind = now < previousUpdate;
|
||||||
const hasExceededRate = now - previousUpdate >= timerConfig.notificationRate;
|
const hasExceededRate = now - previousUpdate >= timerConfig.notificationRate;
|
||||||
const newSeconds = millisToSeconds(previousUpdate) !== millisToSeconds(now);
|
return isClockBehind || hasExceededRate;
|
||||||
return isClockBehind || hasExceededRate || newSeconds;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user