chore: rename offset to offsetAbs and offsetRel (#1706)

This commit is contained in:
Alex Christoffer Rasmussen
2025-08-02 22:01:24 +12:00
committed by Carlos Valente
parent df137402cf
commit bcf80f9d77
12 changed files with 103 additions and 103 deletions
+4 -4
View File
@@ -175,7 +175,7 @@ export const useRuntimePlaybackOverview = createSelector((state: RuntimeStore) =
numEvents: state.runtime.numEvents,
selectedEventIndex: state.runtime.selectedEventIndex,
offset: state.runtime.offsetMode === OffsetMode.Absolute ? state.runtime.offset : state.runtime.relativeOffset,
offset: state.runtime.offsetMode === OffsetMode.Absolute ? state.runtime.offsetAbs : state.runtime.offsetRel,
blockStartedAt: state.blockNow?.startedAt ?? null,
blockExpectedEnd: state.blockNow?.expectedEnd ?? null,
@@ -183,12 +183,12 @@ export const useRuntimePlaybackOverview = createSelector((state: RuntimeStore) =
export const useTimelineStatus = createSelector((state: RuntimeStore) => ({
clock: state.clock,
offset: state.runtime.offset,
offset: state.runtime.offsetAbs,
}));
export const useTimeUntilData = createSelector((state: RuntimeStore) => ({
clock: state.clock,
offset: state.runtime.offsetMode === OffsetMode.Absolute ? state.runtime.offset : state.runtime.relativeOffset,
offset: state.runtime.offsetMode === OffsetMode.Absolute ? state.runtime.offsetAbs : state.runtime.offsetRel,
offsetMode: state.runtime.offsetMode,
currentDay: state.eventNow?.dayOffset ?? 0,
actualStart: state.runtime.actualStart,
@@ -200,7 +200,7 @@ export const useCurrentDay = createSelector((state: RuntimeStore) => ({
}));
export const useRuntimeOffset = createSelector((state: RuntimeStore) => ({
offset: state.runtime.offset,
offset: state.runtime.offsetAbs,
}));
export const usePing = createSelector((state: RuntimeStore) => ({
@@ -46,7 +46,7 @@ export default function StudioTimers({
time.phase === TimerPhase.Danger,
);
const offsetState = getOffsetState(runtime.offset);
const offsetState = getOffsetState(runtime.offsetAbs);
return (
<div className='studio__timers'>
@@ -6,7 +6,7 @@ import { formatTime } from '../../common/utils/time';
const timeFormat = { format12: 'h:mm a', format24: 'HH:mm' };
export function getFormattedScheduleTimes(runtime: Runtime) {
const correctedOffset = runtime.offset !== null ? runtime.offset * -1 : null;
const correctedOffset = runtime.offsetAbs !== null ? runtime.offsetAbs * -1 : null;
return {
actualStart: formatTime(runtime.actualStart, timeFormat),
expectedEnd: formatTime(runtime.expectedEnd, timeFormat),
@@ -54,7 +54,7 @@ export default function TimelinePage({ events, general, runtime, selectedId, set
let followedByStatus: string | undefined;
if (next !== null) {
const timeToStart = getTimeToStart(time.clock, next.timeStart, next?.delay ?? 0, runtime.offset);
const timeToStart = getTimeToStart(time.clock, next.timeStart, next?.delay ?? 0, runtime.offsetAbs);
if (timeToStart < 0) {
nextStatus = dueText;
} else {
@@ -63,7 +63,7 @@ export default function TimelinePage({ events, general, runtime, selectedId, set
}
if (followedBy !== null) {
const timeToStart = getTimeToStart(time.clock, followedBy.timeStart, followedBy?.delay ?? 0, runtime.offset);
const timeToStart = getTimeToStart(time.clock, followedBy.timeStart, followedBy?.delay ?? 0, runtime.offsetAbs);
if (timeToStart < 0) {
followedByStatus = dueText;
} else {
@@ -741,8 +741,8 @@ describe('getRuntimeOffset()', () => {
},
} as RuntimeState;
const { absoluteOffset } = getRuntimeOffset(state);
expect(absoluteOffset).toBe(-50);
const { offsetAbs } = getRuntimeOffset(state);
expect(offsetAbs).toBe(-50);
});
it('added time subtracts time offset (positive offset)', () => {
@@ -765,8 +765,8 @@ describe('getRuntimeOffset()', () => {
},
} as RuntimeState;
const { absoluteOffset } = getRuntimeOffset(state);
expect(absoluteOffset).toBe(-60);
const { offsetAbs } = getRuntimeOffset(state);
expect(offsetAbs).toBe(-60);
});
it('considers running overtime (negative offset)', () => {
@@ -790,8 +790,8 @@ describe('getRuntimeOffset()', () => {
},
} as RuntimeState;
const { absoluteOffset } = getRuntimeOffset(state);
expect(absoluteOffset).toBe(-10);
const { offsetAbs } = getRuntimeOffset(state);
expect(offsetAbs).toBe(-10);
});
it('paused time is delayed time (negative offset)', () => {
@@ -816,8 +816,8 @@ describe('getRuntimeOffset()', () => {
},
} as RuntimeState;
const { absoluteOffset } = getRuntimeOffset(state);
expect(absoluteOffset).toBe(-25);
const { offsetAbs } = getRuntimeOffset(state);
expect(offsetAbs).toBe(-25);
});
it('offset doesnt exist if we havent started', () => {
@@ -834,7 +834,7 @@ describe('getRuntimeOffset()', () => {
runtime: {
selectedEventIndex: 0,
numEvents: 2,
offset: -77400000,
offsetAbs: -77400000,
plannedStart: 77400000,
plannedEnd: 84600000,
actualStart: null,
@@ -854,8 +854,8 @@ describe('getRuntimeOffset()', () => {
_timer: { pausedAt: null },
} as RuntimeState;
const { absoluteOffset } = getRuntimeOffset(state);
expect(absoluteOffset).toBe(0);
const { offsetAbs } = getRuntimeOffset(state);
expect(offsetAbs).toBe(0);
});
it('handles loaded event', () => {
@@ -875,7 +875,7 @@ describe('getRuntimeOffset()', () => {
runtime: {
selectedEventIndex: 1,
numEvents: 2,
offset: -81000000,
offsetAbs: -81000000,
plannedStart: 77400000,
plannedEnd: 84600000,
actualStart: 79443403,
@@ -895,8 +895,8 @@ describe('getRuntimeOffset()', () => {
_timer: { pausedAt: null },
} as RuntimeState;
const { absoluteOffset } = getRuntimeOffset(state);
expect(absoluteOffset).toBe(81000000 - 79521653); // clock - timestart
const { offsetAbs } = getRuntimeOffset(state);
expect(offsetAbs).toBe(81000000 - 79521653); // clock - timestart
});
it('with time-to-end, offsets dont exist if we are not in overtime', () => {
@@ -927,7 +927,7 @@ describe('getRuntimeOffset()', () => {
runtime: {
selectedEventIndex: 0,
numEvents: 1,
offset: 0,
offsetAbs: 0,
plannedStart: 77400000, // 21:30:00
plannedEnd: 81000000, // 22:30:00
actualStart: 78000000, // 21:40:00
@@ -947,8 +947,8 @@ describe('getRuntimeOffset()', () => {
_timer: { pausedAt: null },
} as RuntimeState;
const { absoluteOffset } = getRuntimeOffset(state);
expect(absoluteOffset).toBe(0);
const { offsetAbs } = getRuntimeOffset(state);
expect(offsetAbs).toBe(0);
});
it('with time-to-end, offset is the overtime', () => {
@@ -979,7 +979,7 @@ describe('getRuntimeOffset()', () => {
runtime: {
selectedEventIndex: 0,
numEvents: 1,
offset: 0,
offsetAbs: 0,
plannedStart: 77400000, // 21:30:00
plannedEnd: 81000000, // 22:30:00
actualStart: 78000000, // 21:40:00
@@ -999,8 +999,8 @@ describe('getRuntimeOffset()', () => {
_timer: { pausedAt: null },
} as RuntimeState;
const { absoluteOffset } = getRuntimeOffset(state);
expect(absoluteOffset).toBe(-400000); // <--- offset is always the overtime
const { offsetAbs } = getRuntimeOffset(state);
expect(offsetAbs).toBe(-400000); // <--- offset is always the overtime
});
it('handles time-to-end started after the end time', () => {
@@ -1020,7 +1020,7 @@ describe('getRuntimeOffset()', () => {
runtime: {
selectedEventIndex: 0,
numEvents: 1,
offset: 0,
offsetAbs: 0,
plannedStart: 77400000, // 21:30:00
plannedEnd: 81000000, // 22:30:00
actualStart: 82000000, // 22:46:40 <--- started now
@@ -1042,13 +1042,13 @@ describe('getRuntimeOffset()', () => {
const updateCurrent = getCurrent(state);
state.timer.current = updateCurrent;
const { absoluteOffset } = getRuntimeOffset(state);
expect(millisToString(absoluteOffset)).toBe('-00:16:40');
expect(absoluteOffset).toBe(81000000 - 82000000); // <-- planned end - now
const { offsetAbs } = getRuntimeOffset(state);
expect(millisToString(offsetAbs)).toBe('-00:16:40');
expect(offsetAbs).toBe(81000000 - 82000000); // <-- planned end - now
});
});
describe('getRelativeOffset()', () => {
describe('getoffsetRel()', () => {
it('relative offset is 0 when starting at the planed time', () => {
const state = {
eventNow: {
@@ -1069,9 +1069,9 @@ describe('getRelativeOffset()', () => {
},
} as RuntimeState;
const { absoluteOffset, relativeOffset } = getRuntimeOffset(state);
expect(absoluteOffset).toBe(0);
expect(relativeOffset).toBe(0);
const { offsetAbs, offsetRel } = getRuntimeOffset(state);
expect(offsetAbs).toBe(0);
expect(offsetRel).toBe(0);
});
it('relative offset is 0 when starting after the planed time', () => {
const state = {
@@ -1093,9 +1093,9 @@ describe('getRelativeOffset()', () => {
},
} as RuntimeState;
const { absoluteOffset, relativeOffset } = getRuntimeOffset(state);
expect(absoluteOffset).toBe(-50);
expect(relativeOffset).toBe(0);
const { offsetAbs, offsetRel } = getRuntimeOffset(state);
expect(offsetAbs).toBe(-50);
expect(offsetRel).toBe(0);
});
it('relative offset is 0 when starting before the planed time', () => {
const state = {
@@ -1117,9 +1117,9 @@ describe('getRelativeOffset()', () => {
},
} as RuntimeState;
const { absoluteOffset, relativeOffset } = getRuntimeOffset(state);
expect(absoluteOffset).toBe(50);
expect(relativeOffset).toBe(0);
const { offsetAbs, offsetRel } = getRuntimeOffset(state);
expect(offsetAbs).toBe(50);
expect(offsetRel).toBe(0);
});
});
@@ -1224,7 +1224,7 @@ describe('getTimerPhase()', () => {
runtime: {
selectedEventIndex: null,
numEvents: 1,
offset: 0,
offsetAbs: 0,
plannedStart: 55860000,
plannedEnd: 55880000,
actualStart: null,
@@ -1263,7 +1263,7 @@ describe('getTimerPhase()', () => {
runtime: {
selectedEventIndex: null,
numEvents: 1,
offset: 0,
offsetAbs: 0,
plannedStart: 55860000,
plannedEnd: 55880000,
actualStart: null,
@@ -98,7 +98,7 @@ class RuntimeService {
// 2. handle edge cases related to roll
if (newState.timer.playback === Playback.Roll) {
// check if we need to call any side effects
const keepOffset = newState.runtime.offset;
const keepOffset = newState.runtime.offsetAbs;
if (hasSecondaryTimerFinished) {
// if the secondary timer has finished, we need to call roll
// since event is already loaded
+10 -10
View File
@@ -1,4 +1,4 @@
import { isOntimeEvent, MaybeNumber, OntimeBlock, Rundown, TimerPhase } from 'ontime-types';
import { isOntimeEvent, MaybeNumber, OffsetMode, OntimeBlock, Rundown, TimerPhase } from 'ontime-types';
import { calculateTimeUntilStart, dayInMs, getLastEventNormal, isPlaybackActive } from 'ontime-utils';
import type { RuntimeState } from '../stores/runtimeState.js';
import { shouldCrashDev } from '../utils/development.js';
@@ -43,7 +43,7 @@ export function getExpectedBlockFinish(state: RuntimeState, rundown: Rundown): M
const { lastEvent } = getLastEventNormal(rundown.entries, orderInBlock);
if (!lastEvent) return null;
const { offsetMode, offset, plannedStart, actualStart } = state.runtime;
const { offsetMode, offsetAbs, offsetRel, plannedStart, actualStart } = state.runtime;
const timeUntilLastEvent = calculateTimeUntilStart({
timeStart: lastEvent.timeStart,
@@ -54,7 +54,7 @@ export function getExpectedBlockFinish(state: RuntimeState, rundown: Rundown): M
isLinkedToLoaded,
clock,
offsetMode,
offset,
offset: offsetMode === OffsetMode.Absolute ? offsetAbs : offsetRel,
plannedStart,
actualStart,
});
@@ -171,10 +171,10 @@ export function skippedOutOfEvent(state: RuntimeState, previousTime: number, ski
* Positive offset is time ahead
* Negative offset is time delayed
*/
export function getRuntimeOffset(state: RuntimeState): { absoluteOffset: number; relativeOffset: number } {
export function getRuntimeOffset(state: RuntimeState): { offsetAbs: number; offsetRel: number } {
// nothing to calculate if there are no loaded events or if we havent started
if (state.eventNow === null || state.runtime.actualStart === null) {
return { absoluteOffset: 0, relativeOffset: 0 };
return { offsetAbs: 0, offsetRel: 0 };
}
const { clock } = state;
@@ -192,7 +192,7 @@ export function getRuntimeOffset(state: RuntimeState): { absoluteOffset: number;
// if we havent started, but the timer is armed
// the offset is the difference to the schedule
if (startedAt === null) {
return { absoluteOffset: timeStart - clock, relativeOffset: 0 };
return { offsetAbs: timeStart - clock, offsetRel: 0 };
}
const overtime = Math.min(current, 0);
@@ -211,14 +211,14 @@ export function getRuntimeOffset(state: RuntimeState): { absoluteOffset: number;
const rundownStartOffset = actualStart - plannedStart;
// offset offset relative to the actual rundown start
const relativeOffset = offset + rundownStartOffset;
const offsetRel = offset + rundownStartOffset;
// in time-to-end, offset is overtime
if (countToEnd) {
return { absoluteOffset: overtime, relativeOffset };
return { offsetAbs: overtime, offsetRel };
}
return { absoluteOffset: offset, relativeOffset };
return { offsetAbs: offset, offsetRel };
}
/**
@@ -229,7 +229,7 @@ export function getExpectedEnd(state: RuntimeState): MaybeNumber {
if (state.runtime.actualStart === null || state.runtime.plannedEnd === null) {
return null;
}
return state.runtime.plannedEnd - state.runtime.offset + state._rundown.totalDelay;
return state.runtime.plannedEnd - state.runtime.offsetAbs + state._rundown.totalDelay;
}
/**
@@ -12,8 +12,8 @@ const baseState: RuntimeState = {
runtime: {
selectedEventIndex: null,
numEvents: 0,
offset: 0,
relativeOffset: 0,
offsetAbs: 0,
offsetRel: 0,
plannedStart: 0,
plannedEnd: 0,
actualStart: null,
@@ -185,26 +185,26 @@ describe('mutation on runtimeState', () => {
expect(newState.runtime.plannedStart).toBe(0);
expect(newState.runtime.plannedEnd).toBe(1500);
expect(newState.blockNow).toBeNull();
expect(newState.runtime.offset).toBe(0);
expect(newState.runtime.offsetAbs).toBe(0);
// 2. Start event
start();
newState = getState();
const firstStart = newState.clock;
if (newState.runtime.offset === null) {
if (newState.runtime.offsetAbs === null) {
throw new Error('Value cannot be null at this stage');
}
expect(newState.runtime.actualStart).toBe(newState.clock);
expect(newState.runtime.offset).toBe(entries.event1.timeStart - newState.clock);
expect(newState.runtime.expectedEnd).toBe(entries.event2.timeEnd - newState.runtime.offset);
expect(newState.runtime.offsetAbs).toBe(entries.event1.timeStart - newState.clock);
expect(newState.runtime.expectedEnd).toBe(entries.event2.timeEnd - newState.runtime.offsetAbs);
// 3. Next event
load(entries.event2, rundown, metadata);
start();
newState = getState();
if (newState.runtime.actualStart === null || newState.runtime.offset === null) {
if (newState.runtime.actualStart === null || newState.runtime.offsetAbs === null) {
throw new Error('Value cannot be null at this stage');
}
@@ -214,26 +214,26 @@ describe('mutation on runtimeState', () => {
expect(forgivingActualStart).toBeLessThanOrEqual(1);
// we are over-under, the difference between the schedule and the actual start
const delayBefore = entries.event2.timeStart - newState.clock;
expect(newState.runtime.offset).toBe(delayBefore);
expect(newState.runtime.offsetAbs).toBe(delayBefore);
// finish is the difference between the runtime and the schedule
expect(newState.runtime.expectedEnd).toBe(entries.event2.timeEnd - newState.runtime.offset);
expect(newState.runtime.expectedEnd).toBe(entries.event2.timeEnd - newState.runtime.offsetAbs);
expect(newState.blockNow).toBeNull();
// 4. Add time
addTime(10);
newState = getState();
if (newState.runtime.offset === null) {
if (newState.runtime.offsetAbs === null) {
throw new Error('Value cannot be null at this stage');
}
expect(newState.runtime.offset).toBe(delayBefore - 10);
expect(newState.runtime.expectedEnd).toBe(entries.event2.timeEnd - newState.runtime.offset);
expect(newState.runtime.offsetAbs).toBe(delayBefore - 10);
expect(newState.runtime.expectedEnd).toBe(entries.event2.timeEnd - newState.runtime.offsetAbs);
// 5. Stop event
stop();
newState = getState();
expect(newState.runtime.actualStart).toBeNull();
expect(newState.runtime.offset).toBe(0);
expect(newState.runtime.offsetAbs).toBe(0);
expect(newState.runtime.expectedEnd).toBeNull();
});
});
@@ -325,7 +325,7 @@ describe('roll mode', () => {
start();
const result = roll(rundown, metadata);
expect(result).toStrictEqual({ eventId: '1', didStart: false });
expect(getState().runtime.offset).toBe(1000);
expect(getState().runtime.offsetAbs).toBe(1000);
});
});
@@ -349,21 +349,21 @@ describe('roll mode', () => {
load(rundown.entries[1] as PlayableEvent, rundown, metadata);
start();
// the current offset after manual play
const currentOffset = getState().runtime.offset;
let result = roll(rundown, metadata, getState().runtime.offset);
const currentOffset = getState().runtime.offsetAbs;
let result = roll(rundown, metadata, getState().runtime.offsetAbs);
expect(result).toStrictEqual({ eventId: '1', didStart: false });
// the current offset should be maintain by roll mode whn taking over from play
expect(getState().runtime.offset).toBe(currentOffset);
expect(getState().runtime.offsetAbs).toBe(currentOffset);
vi.setSystemTime('jan 1 00:00:01');
result = roll(rundown, metadata, getState().runtime.offset);
result = roll(rundown, metadata, getState().runtime.offsetAbs);
expect(result).toStrictEqual({ eventId: '2', didStart: true });
expect(getState().runtime.offset).toBe(1000);
expect(getState().runtime.offsetAbs).toBe(1000);
vi.setSystemTime('jan 1 00:00:02');
result = roll(rundown, metadata, getState().runtime.offset);
result = roll(rundown, metadata, getState().runtime.offsetAbs);
expect(result).toStrictEqual({ eventId: '3', didStart: true });
expect(getState().runtime.offset).toBe(1000);
expect(getState().runtime.offsetAbs).toBe(1000);
vi.useRealTimers();
});
+23 -23
View File
@@ -91,8 +91,8 @@ export function clearEventData() {
runtimeState.eventNow = null;
runtimeState.eventNext = null;
runtimeState.runtime.offset = 0;
runtimeState.runtime.relativeOffset = 0;
runtimeState.runtime.offsetAbs = 0;
runtimeState.runtime.offsetRel = 0;
runtimeState.runtime.expectedEnd = null;
runtimeState.runtime.selectedEventIndex = null;
@@ -117,8 +117,8 @@ export function clearState() {
runtimeState.blockNext = null;
runtimeState.nextFlag = null;
runtimeState.runtime.offset = 0;
runtimeState.runtime.relativeOffset = 0;
runtimeState.runtime.offsetAbs = 0;
runtimeState.runtime.offsetRel = 0;
runtimeState.runtime.actualStart = null;
runtimeState.runtime.expectedEnd = null;
runtimeState.runtime.selectedEventIndex = null;
@@ -214,9 +214,9 @@ export function load(
const firstStart = initialData?.firstStart;
if (firstStart === null || typeof firstStart === 'number') {
runtimeState.runtime.actualStart = firstStart;
const { absoluteOffset, relativeOffset } = getRuntimeOffset(runtimeState);
runtimeState.runtime.offset = absoluteOffset;
runtimeState.runtime.relativeOffset = relativeOffset;
const { offsetAbs, offsetRel } = getRuntimeOffset(runtimeState);
runtimeState.runtime.offsetAbs = offsetAbs;
runtimeState.runtime.offsetRel = offsetRel;
runtimeState.runtime.expectedEnd = getExpectedEnd(runtimeState);
}
if (typeof initialData.blockStartAt === 'number' && runtimeState.blockNow) {
@@ -298,7 +298,7 @@ export function updateLoaded(event?: PlayableEvent): string | undefined {
// handle edge cases with roll
if (runtimeState.timer.playback === Playback.Roll) {
const offsetClock = runtimeState.clock + runtimeState.runtime.offset;
const offsetClock = runtimeState.clock + runtimeState.runtime.offsetAbs;
// if waiting to roll, we update the targets and potentially start the timer
if (runtimeState._timer.secondaryTarget !== null) {
if (runtimeState.eventNow.timeStart < offsetClock && offsetClock < runtimeState.eventNow.timeEnd) {
@@ -385,9 +385,9 @@ export function start(state: RuntimeState = runtimeState): boolean {
runtimeState.timer.phase = getTimerPhase(runtimeState);
// update offset
const { absoluteOffset, relativeOffset } = getRuntimeOffset(runtimeState);
runtimeState.runtime.offset = absoluteOffset;
runtimeState.runtime.relativeOffset = relativeOffset;
const { offsetAbs, offsetRel } = getRuntimeOffset(runtimeState);
runtimeState.runtime.offsetAbs = offsetAbs;
runtimeState.runtime.offsetRel = offsetRel;
// as long as there is a timer, we need an planned end
// eslint-disable-next-line no-unused-labels -- dev code path
@@ -397,7 +397,7 @@ export function start(state: RuntimeState = runtimeState): boolean {
}
}
state.runtime.expectedEnd = state.runtime.plannedEnd - state.runtime.offset;
state.runtime.expectedEnd = state.runtime.plannedEnd - state.runtime.offsetAbs;
return true;
}
@@ -457,9 +457,9 @@ export function addTime(amount: number) {
runtimeState.timer.current += amount;
// update runtime delays: over - under
const { absoluteOffset, relativeOffset } = getRuntimeOffset(runtimeState);
runtimeState.runtime.offset = absoluteOffset;
runtimeState.runtime.relativeOffset = relativeOffset;
const { offsetAbs, offsetRel } = getRuntimeOffset(runtimeState);
runtimeState.runtime.offsetAbs = offsetAbs;
runtimeState.runtime.offsetRel = offsetRel;
runtimeState.runtime.expectedEnd = getExpectedEnd(runtimeState);
return true;
@@ -504,9 +504,9 @@ export function update(): UpdateResult {
runtimeState.timer.elapsed = runtimeState.timer.duration - runtimeState.timer.current;
// update runtime, needs up-to-date timer state
const { absoluteOffset, relativeOffset } = getRuntimeOffset(runtimeState);
runtimeState.runtime.offset = absoluteOffset;
runtimeState.runtime.relativeOffset = relativeOffset;
const { offsetAbs, offsetRel } = getRuntimeOffset(runtimeState);
runtimeState.runtime.offsetAbs = offsetAbs;
runtimeState.runtime.offsetRel = offsetRel;
runtimeState.runtime.expectedEnd = getExpectedEnd(runtimeState);
const finishedNow =
@@ -541,7 +541,7 @@ export function update(): UpdateResult {
}
// account for offset
const offsetClock = runtimeState.clock + runtimeState.runtime.offset;
const offsetClock = runtimeState.clock + runtimeState.runtime.offsetAbs;
runtimeState.timer.phase = TimerPhase.Pending;
if (hasCrossedMidnight) {
@@ -575,7 +575,7 @@ export function roll(
}
}
runtimeState.runtime.offset = offset;
runtimeState.runtime.offsetAbs = offset;
runtimeState.timer.playback = Playback.Roll;
// account for event that finishes the day after
@@ -586,7 +586,7 @@ export function roll(
runtimeState.timer.expectedFinish = normalisedEndTime;
//account for offset
const offsetClock = runtimeState.clock + runtimeState.runtime.offset;
const offsetClock = runtimeState.clock + runtimeState.runtime.offsetAbs;
// state catch up
runtimeState.timer.duration = calculateDuration(runtimeState.eventNow.timeStart, normalisedEndTime);
@@ -624,8 +624,8 @@ export function roll(
clearEventData();
//account for offset but we only keep it if passed to us
runtimeState.runtime.offset = offset;
const offsetClock = runtimeState.clock + runtimeState.runtime.offset;
runtimeState.runtime.offsetAbs = offset;
const offsetClock = runtimeState.clock + runtimeState.runtime.offsetAbs;
const { index, isPending } = loadRoll(rundown, metadata, offsetClock);
@@ -8,8 +8,8 @@ export enum OffsetMode {
export type Runtime = {
selectedEventIndex: MaybeNumber;
numEvents: number;
offset: number;
relativeOffset: number;
offsetAbs: number;
offsetRel: number;
plannedStart: MaybeNumber;
actualStart: MaybeNumber;
plannedEnd: MaybeNumber;
@@ -32,8 +32,8 @@ export const runtimeStorePlaceholder: Readonly<RuntimeStore> = {
runtime: {
selectedEventIndex: null, // changes if rundown changes or we load a new event
numEvents: 0, // change initiated by user
offset: 0, // changes at runtime
relativeOffset: 0, // changes at runtime
offsetAbs: 0, // changes at runtime
offsetRel: 0, // changes at runtime
plannedStart: 0, // only changes if event changes
plannedEnd: 0, // only changes if event changes, overflows over dayInMs
actualStart: null, // set once we start the timer