From ed93cf313a9a1c5bd18e48bb35b2eae498ec2115 Mon Sep 17 00:00:00 2001 From: Alex Christoffer Rasmussen Date: Mon, 11 Aug 2025 19:38:09 +0200 Subject: [PATCH] fix: move playing event into group (#1723) * fix: moving paying event into group * add comment --- apps/server/src/stores/runtimeState.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/server/src/stores/runtimeState.ts b/apps/server/src/stores/runtimeState.ts index 3b34fc89e..7cdd07ca7 100644 --- a/apps/server/src/stores/runtimeState.ts +++ b/apps/server/src/stores/runtimeState.ts @@ -358,6 +358,13 @@ export function updateAll(rundown: Rundown, metadata: RundownMetadata) { loadNext(rundown, metadata, eventNowIndex >= 0 ? eventNowIndex : undefined); updateLoaded(runtimeState.eventNow ?? undefined); loadGroupFlagAndEnd(rundown, metadata, eventNowIndex); + + // catch the edge case where the playing event is moved into a group + // if the group already has a start value then we dont overwrite it + // use the start value from the timer, so if the we are not running it will be set to null + if (runtimeState.groupNow && runtimeState.groupNow.startedAt === null) { + runtimeState.groupNow.startedAt = runtimeState.timer.startedAt; + } } export function start(state: RuntimeState = runtimeState): boolean { @@ -713,9 +720,9 @@ function getExpectedTimes(state = runtimeState) { if (state.groupNow) { state.groupNow.expectedEnd = null; const { _group } = state; - if (state.groupNow.startedAt !== null && _group !== null) { - const { event, accumulatedGap, isLinkedToLoaded } = _group; - const expectedStart = getExpectedStart(event, { + if (_group !== null) { + const { event: lastEvent, accumulatedGap, isLinkedToLoaded } = _group; + const lastEventExpectedStart = getExpectedStart(lastEvent, { currentDay: eventNow.dayOffset, totalGap: accumulatedGap, isLinkedToLoaded, @@ -724,7 +731,7 @@ function getExpectedTimes(state = runtimeState) { plannedStart, actualStart, }); - state.groupNow.expectedEnd = expectedStart + event.duration; + state.groupNow.expectedEnd = lastEventExpectedStart + lastEvent.duration; } }