diff --git a/apps/server/src/services/__tests__/timerUtils.test.ts b/apps/server/src/services/__tests__/timerUtils.test.ts index 01cb2d53b..1097a324c 100644 --- a/apps/server/src/services/__tests__/timerUtils.test.ts +++ b/apps/server/src/services/__tests__/timerUtils.test.ts @@ -1558,7 +1558,7 @@ describe('getRuntimeOffset()', () => { } as RuntimeState; const offset = getRuntimeOffset(state); - expect(offset).toBe(null); + expect(offset).toBe(0); }); it('handles loaded event', () => { diff --git a/apps/server/src/services/timerUtils.ts b/apps/server/src/services/timerUtils.ts index af3dc83d2..f746778e7 100644 --- a/apps/server/src/services/timerUtils.ts +++ b/apps/server/src/services/timerUtils.ts @@ -299,10 +299,10 @@ export const updateRoll = (state: RuntimeState) => { * Positive offset is time ahead * Negative offset is time delayed */ -export function getRuntimeOffset(state: RuntimeState): MaybeNumber { +export function getRuntimeOffset(state: RuntimeState): number { // nothing to calculate if there are no loaded events or if we havent started if (state.eventNow === null || state.runtime.actualStart === null) { - return null; + return 0; } const { clock } = state; diff --git a/apps/server/src/stores/__tests__/runtimeState.test.ts b/apps/server/src/stores/__tests__/runtimeState.test.ts index 2e4e06052..a1053dd65 100644 --- a/apps/server/src/stores/__tests__/runtimeState.test.ts +++ b/apps/server/src/stores/__tests__/runtimeState.test.ts @@ -201,7 +201,7 @@ describe('mutation on runtimeState', () => { stop(); newState = getState(); expect(newState.runtime.actualStart).toBeNull(); - expect(newState.runtime.offset).toBeNull(); + expect(newState.runtime.offset).toBe(0); expect(newState.runtime.expectedEnd).toBeNull(); }); diff --git a/apps/server/src/stores/runtimeState.ts b/apps/server/src/stores/runtimeState.ts index f0ef1acb0..70516dcef 100644 --- a/apps/server/src/stores/runtimeState.ts +++ b/apps/server/src/stores/runtimeState.ts @@ -19,7 +19,7 @@ import { timerConfig } from '../config/config.js'; const initialRuntime: Runtime = { selectedEventIndex: null, numEvents: 0, - offset: null, + offset: 0, plannedStart: 0, plannedEnd: 0, actualStart: null, @@ -82,7 +82,7 @@ export function clear() { runtimeState.eventNext = null; runtimeState.publicEventNext = null; - runtimeState.runtime.offset = null; + runtimeState.runtime.offset = 0; runtimeState.runtime.actualStart = null; runtimeState.runtime.expectedEnd = null; runtimeState.runtime.selectedEventIndex = null; diff --git a/packages/types/src/definitions/runtime/Runtime.type.ts b/packages/types/src/definitions/runtime/Runtime.type.ts index 6dd09b723..1fc669d70 100644 --- a/packages/types/src/definitions/runtime/Runtime.type.ts +++ b/packages/types/src/definitions/runtime/Runtime.type.ts @@ -3,7 +3,7 @@ import type { MaybeNumber } from '../../utils/utils.type.js'; export type Runtime = { numEvents: number; selectedEventIndex: MaybeNumber; - offset: MaybeNumber; + offset: number; plannedStart: MaybeNumber; actualStart: MaybeNumber; plannedEnd: MaybeNumber;