@@ -135,18 +135,7 @@ export class RundownTimingCalculator {
135135 let lastSegmentIds : { segmentId : SegmentId ; segmentPlayoutId : SegmentPlayoutId } | undefined = undefined
136136 let nextRundownAnchor : number | undefined = undefined
137137
138- if ( playlist ) {
139- const breakProps = currentRundown ? this . getRundownsBeforeNextBreak ( rundowns , currentRundown ) : undefined
140-
141- if ( breakProps ) {
142- rundownsBeforeNextBreak = breakProps . rundownsBeforeNextBreak
143- breakIsLastRundown = breakProps . breakIsLastRundown
144- }
145-
146- if ( ! playlist . nextPartInfo ) {
147- this . nextSegmentId = undefined
148- }
149-
138+ const iterateParts = ( playlist : DBRundownPlaylist ) => {
150139 partInstances . forEach ( ( partInstance , itIndex ) => {
151140 const partId = partInstance . part . _id
152141 const partInstanceId = ! partInstance . isTemporary ? partInstance . _id : null
@@ -489,7 +478,9 @@ export class RundownTimingCalculator {
489478 partInstance . part . expectedDuration ?? 0
490479 }
491480 } )
481+ }
492482
483+ const accumulate = ( playlist : DBRundownPlaylist ) => {
493484 // This is where the waitAccumulator-generated data in the linearSegLines is used to calculate the countdowns.
494485 // at this point the "waitAccumulator" should be the total sum of all the "waits" in the rundown
495486 let localAccum = 0
@@ -571,7 +562,9 @@ export class RundownTimingCalculator {
571562 }
572563 }
573564 }
565+ }
574566
567+ const iterateSegments = ( playlist : DBRundownPlaylist ) => {
575568 // For the sake of Segment Budget Durations, we need to now iterate over all Segments
576569 let nextSegmentIndex = - 1
577570 let itIndex = - 1
@@ -615,6 +608,23 @@ export class RundownTimingCalculator {
615608 }
616609 }
617610
611+ if ( playlist ) {
612+ const breakProps = currentRundown ? this . getRundownsBeforeNextBreak ( rundowns , currentRundown ) : undefined
613+
614+ if ( breakProps ) {
615+ rundownsBeforeNextBreak = breakProps . rundownsBeforeNextBreak
616+ breakIsLastRundown = breakProps . breakIsLastRundown
617+ }
618+
619+ if ( ! playlist . nextPartInfo ) {
620+ this . nextSegmentId = undefined
621+ }
622+
623+ iterateParts ( playlist )
624+ accumulate ( playlist )
625+ iterateSegments ( playlist )
626+ }
627+
618628 let remainingTimeOnCurrentPart : number | undefined = undefined
619629 let currentPartWillAutoNext = false
620630 let currentSegmentId : SegmentId | null | undefined
0 commit comments