Skip to content

Commit

Permalink
fix: issue where event next was stale
Browse files Browse the repository at this point in the history
  • Loading branch information
cpvalente committed Sep 24, 2024
1 parent 177c9a3 commit e41cdb9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/server/src/services/runtime-service/RuntimeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class RuntimeService {

// we need to reload in a few scenarios:
// 1. we are not confident that changes do not affect running event (eg. all events where changed)
const safeOption = typeof affectedIds === 'undefined';
const safeOption = 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);
Expand Down
4 changes: 4 additions & 0 deletions apps/server/src/stores/runtimeState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ export function loadNext(
return;
}

// temporarily reset this value to simplify loop logic
runtimeState.eventNext = null;

for (let i = eventIndex + 1; i < timedEvents.length; i++) {
const event = timedEvents[i];
// we dont deal with events that are not playable
Expand Down Expand Up @@ -360,6 +363,7 @@ export function updateAll(rundown: OntimeRundown) {
loadNext(timedEvents);
updateLoaded(runtimeState.eventNow ?? undefined);
loadBlock(rundown);
console.log('---->', runtimeState.eventNext.note, timedEvents[1].note);
}

export function start(state: RuntimeState = runtimeState): boolean {
Expand Down

0 comments on commit e41cdb9

Please sign in to comment.