Skip to content

Commit

Permalink
fix: update time in block
Browse files Browse the repository at this point in the history
  • Loading branch information
cpvalente committed Jan 27, 2025
1 parent 5d5b48a commit 7295559
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions apps/server/src/stores/runtimeState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,10 @@ export function roll(rundown: OntimeRundown, offset = 0): { eventId: MaybeString
runtimeState.timer.playback = Playback.Roll;
runtimeState.runtime.numEvents = timedEvents.length;

// update runtime
if (runtimeState.currentBlock.startedAt === null) {
runtimeState.currentBlock.startedAt = runtimeState.clock;
}
// in roll mode spec, there should always be something to load
// as long as playableEvents is not empty
// eslint-disable-next-line no-unused-labels -- dev code path
Expand Down Expand Up @@ -696,13 +700,13 @@ function loadBlock(rundown: OntimeRundown) {

const newCurrentBlock = getPreviousBlock(rundown, runtimeState.eventNow.id);

// test all block change posibiletys
const formNoBlockToBlock = runtimeState.currentBlock.block === null && newCurrentBlock !== null;
const formBlockToNoBlock = runtimeState.currentBlock.block !== null && newCurrentBlock === null;
const formBlockToNewBlock = runtimeState.currentBlock.block?.id !== newCurrentBlock?.id;
// test all block change possibilities
const loadedBlock = runtimeState.currentBlock.block === null && newCurrentBlock !== null;
const unloadedBlock = runtimeState.currentBlock.block !== null && newCurrentBlock === null;
const changedBlock = runtimeState.currentBlock.block?.id !== newCurrentBlock?.id;

// update time only if the block has changed
if (formNoBlockToBlock || formBlockToNoBlock || formBlockToNewBlock) {
if (loadedBlock || unloadedBlock || changedBlock) {
runtimeState.currentBlock.startedAt = null;
}

Expand Down

0 comments on commit 7295559

Please # to comment.