refactor: cap timer values

This commit is contained in:
Carlos Valente
2024-05-18 23:03:35 +02:00
committed by Carlos Valente
parent bb199128aa
commit 119e6caca3
2 changed files with 15 additions and 3 deletions
+12 -2
View File
@@ -1,7 +1,14 @@
import { useCallback } from 'react';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { isOntimeEvent, MaybeString, OntimeEvent, OntimeRundownEntry, RundownCached } from 'ontime-types';
import { getLinkedTimes, getPreviousEventNormal, reorderArray, swapEventData } from 'ontime-utils';
import {
dayInMs,
getLinkedTimes,
getPreviousEventNormal,
MILLIS_PER_SECOND,
reorderArray,
swapEventData,
} from 'ontime-utils';
import { RUNDOWN } from '../api/constants';
import {
@@ -215,9 +222,12 @@ export const useEventAction = () => {
newValMillis = forgivingStringToMillis(value);
}
// dont allow timer values over 23:59:59
const cappedMillis = Math.min(newValMillis, dayInMs - MILLIS_PER_SECOND);
const newEvent = {
id: eventId,
[field]: newValMillis,
[field]: cappedMillis,
};
try {
await _updateEventMutation.mutateAsync(newEvent);