Skip to content

Commit 2e52a33

Browse files
committed
chore: refactor stateCacheResolver utility functions from the webui
1 parent 916a4db commit 2e52a33

2 files changed

Lines changed: 938 additions & 5 deletions

File tree

packages/corelib/src/playout/infinites.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export function buildPastInfinitePiecesForThisPartQuery(
8989
}
9090
}
9191

92+
// This is where we resolve OnChange infinites
9293
export function getPlayheadTrackingInfinitesForPart(
9394
playlistActivationId: RundownPlaylistActivationId,
9495
partsToReceiveOnSegmentEndFromSet: Set<PartId>,
@@ -116,7 +117,7 @@ export function getPlayheadTrackingInfinitesForPart(
116117
return []
117118
}
118119

119-
const canContinueAdlibOnEnds = nextPartIsAfterCurrentPart
120+
const canContinueOnEnds = nextPartIsAfterCurrentPart
120121
interface InfinitePieceSet {
121122
[PieceLifespan.OutOnShowStyleEnd]?: ReadonlyDeep<PieceInstance>
122123
[PieceLifespan.OutOnRundownEnd]?: ReadonlyDeep<PieceInstance>
@@ -178,8 +179,8 @@ export function getPlayheadTrackingInfinitesForPart(
178179
}
179180
}
180181

181-
// Check if we should persist any adlib onEnd infinites
182-
if (canContinueAdlibOnEnds) {
182+
// Check if we should persist any onEnd infinites
183+
if (canContinueOnEnds) {
183184
const piecesByInfiniteMode = groupByToMapFunc(
184185
pieceInstances.filter((p) => p.dynamicallyInserted || p.dynamicallyConvertedToInfinite),
185186
(p) => p.piece.lifespan
@@ -302,7 +303,7 @@ export function isPiecePotentiallyActiveInPart(
302303

303304
switch (pieceToCheck.lifespan) {
304305
case PieceLifespan.WithinPart:
305-
// This must be from another part
306+
// pieceToCheck is from another part since the partId didn't match in the previous check.
306307
return false
307308
case PieceLifespan.OutOnSegmentEnd:
308309
return (
@@ -365,8 +366,11 @@ export function isPiecePotentiallyActiveInPart(
365366
}
366367
}
367368

369+
// TODO: possibly break getPieceInstancesForPart into smaller functions for readabilityl?
370+
368371
/**
369-
* Calculate all of the onEnd PieceInstances for a PartInstance
372+
* Calculate all of the PieceInstances for a PartInstance
373+
* This is where we resolve all infinites. The function contains the logic for OnEnd infinites.
370374
* @param playlistActivationId The current playlist ActivationId
371375
* @param playingPartInstance The current PartInstance, if there is one
372376
* @param playingPieceInstances The PieceInstances from the current PartInstance

0 commit comments

Comments
 (0)