From 6711cdaf4f624c891d87a9a41fb15296b76f77a9 Mon Sep 17 00:00:00 2001 From: Alex Christoffer Rasmussen Date: Wed, 25 Jun 2025 18:17:05 +0200 Subject: [PATCH] fix event next (#1664) --- apps/server/src/stores/__tests__/runtimeState.test.ts | 6 +++++- apps/server/src/stores/runtimeState.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/server/src/stores/__tests__/runtimeState.test.ts b/apps/server/src/stores/__tests__/runtimeState.test.ts index afdceb598..e9353d010 100644 --- a/apps/server/src/stores/__tests__/runtimeState.test.ts +++ b/apps/server/src/stores/__tests__/runtimeState.test.ts @@ -87,7 +87,10 @@ describe('mutation on runtimeState', () => { test('normal playback cycle', async () => { // 1. Load event - const mockRundown = makeRundown({ entries: { [mockEvent.id]: mockEvent }, order: [mockEvent.id] }); + const mockRundown = makeRundown({ + entries: { [mockEvent.id]: mockEvent, event2: { ...mockEvent, id: 'event2' } }, + order: [mockEvent.id, 'event2'], + }); // force update vi.useFakeTimers(); await initRundown(mockRundown, {}); @@ -98,6 +101,7 @@ describe('mutation on runtimeState', () => { load(mockEvent, rundown, metadata); let newState = getState(); expect(newState.eventNow?.id).toBe(mockEvent.id); + expect(newState.eventNext?.id).toBe('event2'); expect(newState.timer.playback).toBe(Playback.Armed); expect(newState.clock).not.toBe(666); expect(newState.currentBlock.block).toBeNull(); diff --git a/apps/server/src/stores/runtimeState.ts b/apps/server/src/stores/runtimeState.ts index 5a0a1b92f..d9f1e0483 100644 --- a/apps/server/src/stores/runtimeState.ts +++ b/apps/server/src/stores/runtimeState.ts @@ -249,7 +249,7 @@ export function loadNext( } const nowPlayableIndex = getPlayableIndexFromTimedIndex(metadata, eventIndex); - if (!nowPlayableIndex || nowPlayableIndex > metadata.playableEventOrder.length - 2) { + if (nowPlayableIndex === null || nowPlayableIndex > metadata.playableEventOrder.length - 2) { // we cound not find the event now or the event now is the last playable event runtimeState.eventNext = null; return;