From 66ed92e215096c47eb7512bd63c44be14718f42c Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Fri, 9 Aug 2024 19:58:28 +0200 Subject: [PATCH] fix: stop playback when event is deleted --- apps/server/src/services/runtime-service/RuntimeService.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/server/src/services/runtime-service/RuntimeService.ts b/apps/server/src/services/runtime-service/RuntimeService.ts index 0782cb4fe..f066bba13 100644 --- a/apps/server/src/services/runtime-service/RuntimeService.ts +++ b/apps/server/src/services/runtime-service/RuntimeService.ts @@ -231,19 +231,23 @@ class RuntimeService { // 1. we are not confident that changes do not affect running event (eg. all events where changed) const safeOption = typeof affectedIds === 'undefined'; // 2. the edited event is in memory (now or next) running + // behind conditional to avoid doing unnecessary work const eventInMemory = safeOption ? false : this.affectsLoaded(affectedIds); // 3. the edited event replaces next event let isNext = false; - // TODO: review logic + // if we are not sure, or the event is in memory, we reload if (safeOption || eventInMemory) { if (state.eventNow !== null) { // load stuff again, but keep running if our events still exist const eventNow = getEventWithId(state.eventNow.id); if (!isOntimeEvent(eventNow) || !isPlayableEvent(eventNow)) { + // maybe the event was deleted or the skip state was changed + runtimeState.stop(); return; } const onlyChangedNow = affectedIds?.length === 1 && affectedIds.at(0) === eventNow.id; + if (onlyChangedNow) { runtimeState.reload(eventNow); } else {