@@ -178,20 +178,23 @@ export async function performTakeToNextedPart(
178
178
}
179
179
}
180
180
181
+ // If hold is COMPLETE, clear the hold state by this take
181
182
if ( playoutModel . playlist . holdState === RundownHoldState . COMPLETE ) {
182
183
playoutModel . setHoldState ( RundownHoldState . NONE )
183
184
184
- // If hold is active , then this take is to clear it
185
+ // If hold is ACTIVE , then this take is to complete it
185
186
} else if ( playoutModel . playlist . holdState === RundownHoldState . ACTIVE ) {
186
187
await completeHold ( context , playoutModel , await pShowStyle , currentPartInstance )
187
188
189
+ await updateTimeline ( context , playoutModel )
190
+
188
191
if ( span ) span . end ( )
189
192
190
193
return
191
194
}
192
195
193
196
const takePartInstance = nextPartInstance
194
- if ( ! takePartInstance ) throw new Error ( 'takePart not found!' )
197
+ if ( ! takePartInstance ) throw new Error ( 'takePartInstance not found!' )
195
198
const takeRundown = playoutModel . getRundown ( takePartInstance . partInstance . rundownId )
196
199
if ( ! takeRundown )
197
200
throw new Error ( `takeRundown: takeRundown not found! ("${ takePartInstance . partInstance . rundownId } ")` )
@@ -263,12 +266,10 @@ export async function performTakeToNextedPart(
263
266
// Once everything is synced, we can choose the next part
264
267
await setNextPart ( context , playoutModel , nextPart , false )
265
268
266
- // Setup the parts for the HOLD we are starting
267
- if (
268
- playoutModel . playlist . previousPartInfo &&
269
- ( playoutModel . playlist . holdState as RundownHoldState ) === RundownHoldState . ACTIVE
270
- ) {
271
- startHold ( context , currentPartInstance , nextPartInstance )
269
+ // If the Hold is PENDING, make it active
270
+ if ( playoutModel . playlist . holdState === RundownHoldState . PENDING ) {
271
+ // Setup the parts for the HOLD we are starting
272
+ activateHold ( context , playoutModel , currentPartInstance , takePartInstance )
272
273
}
273
274
await afterTake ( context , playoutModel , takePartInstance )
274
275
@@ -535,35 +536,39 @@ export async function afterTake(
535
536
/**
536
537
* A Hold starts by extending the "extendOnHold"-able pieces in the previous Part.
537
538
*/
538
- function startHold (
539
+ function activateHold (
539
540
context : JobContext ,
541
+ playoutModel : PlayoutModel ,
540
542
holdFromPartInstance : PlayoutPartInstanceModel | null ,
541
543
holdToPartInstance : PlayoutPartInstanceModel | undefined
542
544
) {
543
545
if ( ! holdFromPartInstance ) throw new Error ( 'previousPart not found!' )
544
546
if ( ! holdToPartInstance ) throw new Error ( 'currentPart not found!' )
545
- const span = context . startSpan ( 'startHold' )
547
+ const span = context . startSpan ( 'activateHold' )
548
+
549
+ playoutModel . setHoldState ( RundownHoldState . ACTIVE )
546
550
547
551
// Make a copy of any item which is flagged as an 'infinite' extension
548
552
const pieceInstancesToCopy = holdFromPartInstance . pieceInstances . filter ( ( p ) => ! ! p . pieceInstance . piece . extendOnHold )
549
- pieceInstancesToCopy . forEach ( ( instance ) => {
550
- if ( ! instance . pieceInstance . infinite ) {
551
- // mark current one as infinite
552
- instance . prepareForHold ( )
553
-
554
- // This gets deleted once the nextpart is activated, so it doesnt linger for long
555
- const extendedPieceInstance = holdToPartInstance . insertHoldPieceInstance ( instance )
556
-
557
- const content = clone ( instance . pieceInstance . piece . content ) as VTContent | undefined
558
- if ( content ?. fileName && content . sourceDuration && instance . pieceInstance . plannedStartedPlayback ) {
559
- content . seek = Math . min (
560
- content . sourceDuration ,
561
- getCurrentTime ( ) - instance . pieceInstance . plannedStartedPlayback
562
- )
563
- }
564
- extendedPieceInstance . updatePieceProps ( { content } )
553
+ for ( const instance of pieceInstancesToCopy ) {
554
+ // skip any infinites
555
+ if ( instance . pieceInstance . infinite ) continue
556
+
557
+ instance . prepareForHold ( )
558
+
559
+ // This gets deleted once the nextpart is activated, so it doesnt linger for long
560
+ const extendedPieceInstance = holdToPartInstance . insertHoldPieceInstance ( instance )
561
+
562
+ const content = clone ( instance . pieceInstance . piece . content ) as VTContent | undefined
563
+ if ( content ?. fileName && content . sourceDuration && instance . pieceInstance . plannedStartedPlayback ) {
564
+ content . seek = Math . min (
565
+ content . sourceDuration ,
566
+ getCurrentTime ( ) - instance . pieceInstance . plannedStartedPlayback
567
+ )
565
568
}
566
- } )
569
+ extendedPieceInstance . updatePieceProps ( { content } )
570
+ }
571
+
567
572
if ( span ) span . end ( )
568
573
}
569
574
@@ -575,19 +580,16 @@ async function completeHold(
575
580
) : Promise < void > {
576
581
playoutModel . setHoldState ( RundownHoldState . COMPLETE )
577
582
578
- if ( playoutModel . playlist . currentPartInfo ) {
579
- if ( ! currentPartInstance ) throw new Error ( 'currentPart not found!' )
583
+ if ( ! playoutModel . playlist . currentPartInfo ) return
584
+ if ( ! currentPartInstance ) throw new Error ( 'currentPart not found!' )
580
585
581
- // Clear the current extension line
582
- innerStopPieces (
583
- context ,
584
- playoutModel ,
585
- showStyleCompound . sourceLayers ,
586
- currentPartInstance ,
587
- ( p ) => ! ! p . infinite ?. fromHold ,
588
- undefined
589
- )
590
- }
591
-
592
- await updateTimeline ( context , playoutModel )
586
+ // Clear the current extension line
587
+ innerStopPieces (
588
+ context ,
589
+ playoutModel ,
590
+ showStyleCompound . sourceLayers ,
591
+ currentPartInstance ,
592
+ ( p ) => ! ! p . infinite ?. fromHold ,
593
+ undefined
594
+ )
593
595
}
0 commit comments