Skip to content

Commit 4d3a4cd

Browse files
committed
chore: refactor stateCacheResolver utility functions from the webui
1 parent dbe14a4 commit 4d3a4cd

File tree

2 files changed

+938
-5
lines changed

2 files changed

+938
-5
lines changed

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),
185186
(p) => p.piece.lifespan
@@ -299,7 +300,7 @@ export function isPiecePotentiallyActiveInPart(
299300

300301
switch (pieceToCheck.lifespan) {
301302
case PieceLifespan.WithinPart:
302-
// This must be from another part
303+
// pieceToCheck is from another part since the partId didn't match in the previous check.
303304
return false
304305
case PieceLifespan.OutOnSegmentEnd:
305306
return (
@@ -362,8 +363,11 @@ export function isPiecePotentiallyActiveInPart(
362363
}
363364
}
364365

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

0 commit comments

Comments
 (0)