mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-16 04:43:35 +00:00
Fix current block (#1170)
* pass full rundown to loadNow * remove prevBlock from state * refactor: simplify load logic (#1174) * send clock to client on block start to avoid it showing -1 in the client --------- Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
49467c66b7
commit
f708dc0bc4
@@ -303,20 +303,21 @@ export function getEventWithId(rundown: OntimeRundown, id: string): OntimeRundow
|
||||
* Gets relevant block element for a given ID
|
||||
*/
|
||||
export function getRelevantBlock(rundown: OntimeRundown, currentId: string): OntimeBlock | null {
|
||||
let inBlock = false;
|
||||
let foundCurrentEvent = false;
|
||||
// Iterate backwards through the rundown to find the current event
|
||||
for (let i = rundown.length - 1; i >= 0; i--) {
|
||||
const entry = rundown[i];
|
||||
if (entry.id === currentId) {
|
||||
//set the flag when the current event is found
|
||||
inBlock = true;
|
||||
if (!foundCurrentEvent && entry.id === currentId) {
|
||||
// set the flag when the current event is found
|
||||
foundCurrentEvent = true;
|
||||
continue;
|
||||
}
|
||||
//the first block before the current event is the relevant one
|
||||
if (inBlock && isOntimeBlock(entry)) {
|
||||
// the first block before the current event is the relevant one
|
||||
if (foundCurrentEvent && isOntimeBlock(entry)) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
//no blocks exist before current event
|
||||
// no blocks exist before current event
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user