mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-10 08:39:34 +00:00
refactor: move totalDelay to _rundown
This commit is contained in:
@@ -1248,9 +1248,11 @@ describe('getTimerPhase()', () => {
|
|||||||
},
|
},
|
||||||
_timer: {
|
_timer: {
|
||||||
forceFinish: null,
|
forceFinish: null,
|
||||||
totalDelay: 0,
|
|
||||||
pausedAt: null,
|
pausedAt: null,
|
||||||
},
|
},
|
||||||
|
_rundown: {
|
||||||
|
totalDelay: 0,
|
||||||
|
},
|
||||||
} as RuntimeState;
|
} as RuntimeState;
|
||||||
|
|
||||||
const phase = getTimerPhase(state);
|
const phase = getTimerPhase(state);
|
||||||
@@ -1287,9 +1289,11 @@ describe('getTimerPhase()', () => {
|
|||||||
},
|
},
|
||||||
_timer: {
|
_timer: {
|
||||||
forceFinish: null,
|
forceFinish: null,
|
||||||
totalDelay: 0,
|
|
||||||
pausedAt: null,
|
pausedAt: null,
|
||||||
},
|
},
|
||||||
|
_rundown: {
|
||||||
|
totalDelay: 0,
|
||||||
|
},
|
||||||
} as RuntimeState;
|
} as RuntimeState;
|
||||||
|
|
||||||
const phase = getTimerPhase(state);
|
const phase = getTimerPhase(state);
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ export function getExpectedEnd(state: RuntimeState): MaybeNumber {
|
|||||||
if (state.runtime.actualStart === null || state.runtime.plannedEnd === null) {
|
if (state.runtime.actualStart === null || state.runtime.plannedEnd === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return state.runtime.plannedEnd - state.runtime.offset + state._timer.totalDelay;
|
return state.runtime.plannedEnd - state.runtime.offset + state._rundown.totalDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,10 +37,12 @@ const baseState: RuntimeState = {
|
|||||||
},
|
},
|
||||||
_timer: {
|
_timer: {
|
||||||
forceFinish: null,
|
forceFinish: null,
|
||||||
totalDelay: 0,
|
|
||||||
pausedAt: null,
|
pausedAt: null,
|
||||||
secondaryTarget: null,
|
secondaryTarget: null,
|
||||||
},
|
},
|
||||||
|
_rundown: {
|
||||||
|
totalDelay: 0,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export function makeRuntimeStateData(patch?: Partial<RuntimeState>): RuntimeState {
|
export function makeRuntimeStateData(patch?: Partial<RuntimeState>): RuntimeState {
|
||||||
|
|||||||
@@ -47,10 +47,12 @@ export type RuntimeState = {
|
|||||||
// private properties of the timer calculations
|
// private properties of the timer calculations
|
||||||
_timer: {
|
_timer: {
|
||||||
forceFinish: MaybeNumber; // whether we should declare an event as finished, will contain the finish time
|
forceFinish: MaybeNumber; // whether we should declare an event as finished, will contain the finish time
|
||||||
totalDelay: number; // this value comes from rundown service
|
|
||||||
pausedAt: MaybeNumber;
|
pausedAt: MaybeNumber;
|
||||||
secondaryTarget: MaybeNumber;
|
secondaryTarget: MaybeNumber;
|
||||||
};
|
};
|
||||||
|
_rundown: {
|
||||||
|
totalDelay: number; // this value comes from rundown service
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const runtimeState: RuntimeState = {
|
const runtimeState: RuntimeState = {
|
||||||
@@ -64,10 +66,12 @@ const runtimeState: RuntimeState = {
|
|||||||
timer: { ...runtimeStorePlaceholder.timer },
|
timer: { ...runtimeStorePlaceholder.timer },
|
||||||
_timer: {
|
_timer: {
|
||||||
forceFinish: null,
|
forceFinish: null,
|
||||||
totalDelay: 0,
|
|
||||||
pausedAt: null,
|
pausedAt: null,
|
||||||
secondaryTarget: null,
|
secondaryTarget: null,
|
||||||
},
|
},
|
||||||
|
_rundown: {
|
||||||
|
totalDelay: 0,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getState(): Readonly<RuntimeState> {
|
export function getState(): Readonly<RuntimeState> {
|
||||||
@@ -81,6 +85,7 @@ export function getState(): Readonly<RuntimeState> {
|
|||||||
runtime: { ...runtimeState.runtime },
|
runtime: { ...runtimeState.runtime },
|
||||||
timer: { ...runtimeState.timer },
|
timer: { ...runtimeState.timer },
|
||||||
_timer: { ...runtimeState._timer },
|
_timer: { ...runtimeState._timer },
|
||||||
|
_rundown: { totalDelay: 0 },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +170,7 @@ type RundownData = {
|
|||||||
*/
|
*/
|
||||||
export function updateRundownData(rundownData: RundownData) {
|
export function updateRundownData(rundownData: RundownData) {
|
||||||
// we keep this in private state since there is no UI use case for it
|
// we keep this in private state since there is no UI use case for it
|
||||||
runtimeState._timer.totalDelay = rundownData.totalDelay;
|
runtimeState._rundown.totalDelay = rundownData.totalDelay;
|
||||||
|
|
||||||
runtimeState.runtime.numEvents = rundownData.numEvents;
|
runtimeState.runtime.numEvents = rundownData.numEvents;
|
||||||
runtimeState.runtime.plannedStart = rundownData.firstStart;
|
runtimeState.runtime.plannedStart = rundownData.firstStart;
|
||||||
|
|||||||
Reference in New Issue
Block a user