1- import { BlueprintId , TimelineHash } from '@sofie-automation/corelib/dist/dataModel/Ids'
1+ import { BlueprintId , RundownPlaylistId , TimelineHash } from '@sofie-automation/corelib/dist/dataModel/Ids'
22import { JobContext , JobStudio } from '../../jobs'
33import { ReadonlyDeep } from 'type-fest'
44import {
@@ -388,37 +388,8 @@ async function getTimelineRundown(
388388 timelineObjs = timelineObjs . concat ( rundownTimelineResult . timeline )
389389 timelineObjs = timelineObjs . concat ( await pLookaheadObjs )
390390
391- let regenerateTimelineToken : string | undefined
392- const regenerateTimelineAt = Math . min (
393- partInstancesInfo . current ?. regenerateTimelineAt ?? Number . POSITIVE_INFINITY ,
394- partInstancesInfo . next ?. regenerateTimelineAt ?? Number . POSITIVE_INFINITY
395- )
396- if ( regenerateTimelineAt < Number . POSITIVE_INFINITY ) {
397- // The timeline has requested a regeneration at a specific time
398- regenerateTimelineToken = getHash ( `regenerate-${ playoutModel . playlistId } -${ getCurrentTime ( ) } ` )
399- timelineObjs . push (
400- literal < TimelineObjRegenerateTrigger & OnGenerateTimelineObjExt > ( {
401- id : `regenerate_${ regenerateTimelineToken } ` ,
402- enable : {
403- start : regenerateTimelineAt ,
404- } ,
405- layer : '__timeline_regeneration_trigger__' , // Some unique name, as callbacks need to be on a layer
406- priority : 1 ,
407- content : {
408- deviceType : TSR . DeviceType . ABSTRACT ,
409- type : 'callback' ,
410- callBack : PlayoutChangedType . TRIGGER_REGENERATION ,
411- callBackData : {
412- rundownPlaylistId : playoutModel . playlistId ,
413- regenerationToken : regenerateTimelineToken ,
414- } ,
415- } ,
416- objectType : TimelineObjType . RUNDOWN ,
417- metaData : undefined ,
418- partInstanceId : null ,
419- } )
420- )
421- }
391+ const regenerateTimelineObj = createRegenerateTimelineObj ( playoutModel . playlistId , partInstancesInfo )
392+ if ( regenerateTimelineObj ) timelineObjs . push ( regenerateTimelineObj . obj )
422393
423394 const blueprint = await context . getShowStyleBlueprint ( showStyle . _id )
424395 timelineVersions = generateTimelineVersions (
@@ -517,7 +488,7 @@ async function getTimelineRundown(
517488 } ) ,
518489 versions : timelineVersions ?? generateTimelineVersions ( context . studio , undefined , '-' ) ,
519490 timingContext : rundownTimelineResult . timingContext ,
520- regenerateTimelineToken,
491+ regenerateTimelineToken : regenerateTimelineObj ?. token ,
521492 }
522493 } else {
523494 if ( span ) span . end ( )
@@ -541,6 +512,44 @@ async function getTimelineRundown(
541512 }
542513}
543514
515+ function createRegenerateTimelineObj (
516+ playlistId : RundownPlaylistId ,
517+ partInstancesInfo : SelectedPartInstancesTimelineInfo
518+ ) {
519+ const regenerateTimelineAt = Math . min (
520+ partInstancesInfo . current ?. regenerateTimelineAt ?? Number . POSITIVE_INFINITY ,
521+ partInstancesInfo . next ?. regenerateTimelineAt ?? Number . POSITIVE_INFINITY
522+ )
523+ if ( regenerateTimelineAt < Number . POSITIVE_INFINITY ) {
524+ // The timeline has requested a regeneration at a specific time
525+ const token = getHash ( `regenerate-${ playlistId } -${ getCurrentTime ( ) } ` )
526+ const obj = literal < TimelineObjRegenerateTrigger & OnGenerateTimelineObjExt > ( {
527+ id : `regenerate_${ token } ` ,
528+ enable : {
529+ start : regenerateTimelineAt ,
530+ } ,
531+ layer : '__timeline_regeneration_trigger__' , // Some unique name, as callbacks need to be on a layer
532+ priority : 1 ,
533+ content : {
534+ deviceType : TSR . DeviceType . ABSTRACT ,
535+ type : 'callback' ,
536+ callBack : PlayoutChangedType . TRIGGER_REGENERATION ,
537+ callBackData : {
538+ rundownPlaylistId : playlistId ,
539+ regenerationToken : token ,
540+ } ,
541+ } ,
542+ objectType : TimelineObjType . RUNDOWN ,
543+ metaData : undefined ,
544+ partInstanceId : null ,
545+ } )
546+
547+ return { token, obj }
548+ } else {
549+ return null
550+ }
551+ }
552+
544553/**
545554 * Process the timeline objects, to provide some basic validation. Also flattens the nested objects into a single array
546555 * Note: Input array is mutated in place
0 commit comments