fix: group expected end

This commit is contained in:
Carlos Valente
2025-07-14 09:22:34 +02:00
parent 1e5081f4a2
commit 92a34cf135
2 changed files with 10 additions and 8 deletions
+9 -7
View File
@@ -1,5 +1,5 @@
import { isOntimeEvent, MaybeNumber, OntimeBlock, OntimeEvent, Rundown, TimerPhase } from 'ontime-types';
import { calculateTimeUntilStart, dayInMs, isPlaybackActive } from 'ontime-utils';
import { isOntimeEvent, MaybeNumber, OntimeBlock, Rundown, TimerPhase } from 'ontime-types';
import { calculateTimeUntilStart, dayInMs, getLastEventNormal, isPlaybackActive } from 'ontime-utils';
import type { RuntimeState } from '../stores/runtimeState.js';
import { shouldCrashDev } from '../utils/development.js';
@@ -40,13 +40,15 @@ export function getExpectedBlockFinish(state: RuntimeState, rundown: Rundown): M
isLinkedToLoaded = isLinkedToLoaded && entry.linkStart;
}
}
const lastEntry = entries[orderInBlock.at(-1)!] as OntimeEvent;
const { lastEvent } = getLastEventNormal(rundown.entries, orderInBlock);
if (!lastEvent) return null;
const { offsetMode, offset, plannedStart, actualStart } = state.runtime;
const timeUntilLastEvent = calculateTimeUntilStart({
timeStart: lastEntry.timeStart,
dayOffset: lastEntry.dayOffset,
delay: lastEntry.delay,
timeStart: lastEvent.timeStart,
dayOffset: lastEvent.dayOffset,
delay: lastEvent.delay,
currentDay: eventNow.dayOffset,
totalGap,
isLinkedToLoaded,
@@ -57,7 +59,7 @@ export function getExpectedBlockFinish(state: RuntimeState, rundown: Rundown): M
actualStart,
});
return clock + timeUntilLastEvent + lastEntry.duration;
return clock + timeUntilLastEvent + lastEvent.duration;
}
/**
+1 -1
View File
@@ -723,7 +723,7 @@ export function loadBlock(rundown: Rundown, state = runtimeState) {
//we went into a new block - and it is different from the one we might have come from
if ((state.blockNow != null && state.blockNow.id != currentBlockId) || state.blockNow == null) {
state.blockNow = { id: currentBlockId, startedAt: null, expectedEnd: null }; // the id is set here, the start time is set in other placed that handel starting events
state.blockNow = { id: currentBlockId, startedAt: null, expectedEnd: null }; // the id is set here, the start time is set when starting events
}
}