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 30, 2025
1 parent 5d5b48a commit 6bcb398
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions apps/server/src/stores/runtimeState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,11 @@ export function roll(rundown: OntimeRundown, offset = 0): { eventId: MaybeString

// there is something to run, load event

// update runtime
if (runtimeState.currentBlock.startedAt === null) {
runtimeState.currentBlock.startedAt = runtimeState.clock;
}

// event will finish on time
// account for event that finishes the day after
const endTime =
Expand Down Expand Up @@ -696,13 +701,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 6bcb398

Please sign in to comment.