mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-13 19:33:46 +00:00
add relevantBlock function (#1100)
* feat: current block * pass full rundown to functions and use filter utils
This commit is contained in:
committed by
GitHub
parent
20838c038a
commit
158ef05ff0
@@ -127,10 +127,14 @@ type RollTimers = {
|
||||
|
||||
/**
|
||||
* Finds loading information given a current rundown and time
|
||||
* @param {OntimeEvent[]} rundown - List of playable events
|
||||
* @param {OntimeEvent[]} playableEvents - List of playable events
|
||||
* @param {number} timeNow - time now in ms
|
||||
*/
|
||||
export const getRollTimers = (rundown: OntimeEvent[], timeNow: number, currentIndex?: number | null): RollTimers => {
|
||||
export const getRollTimers = (
|
||||
playableEvents: OntimeEvent[],
|
||||
timeNow: number,
|
||||
currentIndex?: number | null,
|
||||
): RollTimers => {
|
||||
let nowIndex: MaybeNumber = null; // index of event now
|
||||
let nowId: MaybeString = null; // id of event now
|
||||
let publicIndex: MaybeNumber = null; // index of public event now
|
||||
@@ -140,8 +144,8 @@ export const getRollTimers = (rundown: OntimeEvent[], timeNow: number, currentIn
|
||||
let publicTimeToNext: MaybeNumber = null; // counter: time for next public event
|
||||
|
||||
const hasLoaded = currentIndex !== null;
|
||||
const canFilter = hasLoaded && currentIndex === rundown.length - 1;
|
||||
const filteredRundown = canFilter ? rundown.slice(currentIndex) : rundown;
|
||||
const canFilter = hasLoaded && currentIndex === playableEvents.length - 1;
|
||||
const filteredRundown = canFilter ? playableEvents.slice(currentIndex) : playableEvents;
|
||||
|
||||
const lastEvent = filteredRundown.at(-1);
|
||||
const lastNormalEnd = normaliseEndTime(lastEvent.timeStart, lastEvent.timeEnd);
|
||||
|
||||
Reference in New Issue
Block a user