mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-10 16:49:41 +00:00
fix: prevent mutation of initial object
This commit is contained in:
committed by
Carlos Valente
parent
5977266332
commit
6f80de58ca
@@ -80,6 +80,8 @@ export function generate(
|
|||||||
links = {};
|
links = {};
|
||||||
firstStart = null;
|
firstStart = null;
|
||||||
lastEnd = null;
|
lastEnd = null;
|
||||||
|
totalDuration = 0;
|
||||||
|
totalDelay = 0;
|
||||||
|
|
||||||
let accumulatedDelay = 0;
|
let accumulatedDelay = 0;
|
||||||
let daySpan = 0;
|
let daySpan = 0;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const initialRuntime: Runtime = {
|
|||||||
plannedEnd: 0,
|
plannedEnd: 0,
|
||||||
actualStart: null,
|
actualStart: null,
|
||||||
expectedEnd: null,
|
expectedEnd: null,
|
||||||
};
|
} as const;
|
||||||
|
|
||||||
const initialTimer: TimerState = {
|
const initialTimer: TimerState = {
|
||||||
addedTime: 0,
|
addedTime: 0,
|
||||||
@@ -35,7 +35,7 @@ const initialTimer: TimerState = {
|
|||||||
playback: Playback.Stop,
|
playback: Playback.Stop,
|
||||||
secondaryTimer: null,
|
secondaryTimer: null,
|
||||||
startedAt: null,
|
startedAt: null,
|
||||||
};
|
} as const;
|
||||||
|
|
||||||
export type RuntimeState = {
|
export type RuntimeState = {
|
||||||
clock: number; // realtime clock
|
clock: number; // realtime clock
|
||||||
@@ -59,7 +59,7 @@ const runtimeState: RuntimeState = {
|
|||||||
publicEventNow: null,
|
publicEventNow: null,
|
||||||
eventNext: null,
|
eventNext: null,
|
||||||
publicEventNext: null,
|
publicEventNext: null,
|
||||||
runtime: initialRuntime,
|
runtime: { ...initialRuntime },
|
||||||
timer: { ...initialTimer },
|
timer: { ...initialTimer },
|
||||||
_timer: {
|
_timer: {
|
||||||
totalDelay: 0,
|
totalDelay: 0,
|
||||||
@@ -78,12 +78,9 @@ export function clear() {
|
|||||||
runtimeState.eventNext = null;
|
runtimeState.eventNext = null;
|
||||||
runtimeState.publicEventNext = null;
|
runtimeState.publicEventNext = null;
|
||||||
|
|
||||||
runtimeState.runtime = {
|
runtimeState.runtime.offset = null;
|
||||||
...initialRuntime,
|
runtimeState.runtime.actualStart = null;
|
||||||
// persist session stuff
|
runtimeState.runtime.expectedEnd = null;
|
||||||
actualStart: runtimeState.runtime.actualStart,
|
|
||||||
numEvents: runtimeState.runtime.numEvents,
|
|
||||||
};
|
|
||||||
|
|
||||||
runtimeState.timer.playback = Playback.Stop;
|
runtimeState.timer.playback = Playback.Stop;
|
||||||
runtimeState.clock = clock.timeNow();
|
runtimeState.clock = clock.timeNow();
|
||||||
@@ -123,7 +120,7 @@ export function updateRundownData(rundownData: RundownData) {
|
|||||||
|
|
||||||
runtimeState.runtime.numEvents = rundownData.numEvents;
|
runtimeState.runtime.numEvents = rundownData.numEvents;
|
||||||
runtimeState.runtime.plannedStart = rundownData.firstStart;
|
runtimeState.runtime.plannedStart = rundownData.firstStart;
|
||||||
runtimeState.runtime.plannedEnd = rundownData.firstStart + rundownData.totalDuration;
|
runtimeState.runtime.plannedEnd = rundownData.lastEnd;
|
||||||
runtimeState.runtime.expectedEnd = getExpectedEnd(runtimeState);
|
runtimeState.runtime.expectedEnd = getExpectedEnd(runtimeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user