File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
job-worker/src/playout/model/implementation Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1+ import { DBRundown } from '../dataModel/Rundown'
12import { DBSegment } from '../dataModel/Segment'
23import { DBPart } from '../dataModel/Part'
34import { DBPartInstance } from '../dataModel/PartInstance'
@@ -89,3 +90,22 @@ export function sortRundownIDsInPlaylist(
8990
9091 return [ ...sortedVerifiedExisting , ...missingIds ]
9192}
93+
94+ export function sortRundownsWithinPlaylist (
95+ sortedPossibleIds : ReadonlyDeep < RundownId [ ] > ,
96+ unsortedRundowns : DBRundown [ ]
97+ ) : DBRundown [ ] {
98+ return unsortedRundowns . slice ( ) . sort ( ( a , b ) => {
99+ const indexA = sortedPossibleIds . indexOf ( a . _id )
100+ const indexB = sortedPossibleIds . indexOf ( b . _id )
101+ if ( indexA === - 1 && indexB === - 1 ) {
102+ return a . _id . toString ( ) . localeCompare ( b . _id . toString ( ) )
103+ } else if ( indexA === - 1 ) {
104+ return - 1
105+ } else if ( indexB === - 1 ) {
106+ return 1
107+ }
108+
109+ return indexA - indexB
110+ } )
111+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import { PeripheralDevice } from '@sofie-automation/corelib/dist/dataModel/Perip
2222import { PlayoutModel , PlayoutModelPreInit } from '../PlayoutModel'
2323import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part'
2424import { RundownBaselineObj } from '@sofie-automation/corelib/dist/dataModel/RundownBaselineObj'
25+ import { sortRundownsWithinPlaylist } from '@sofie-automation/corelib/dist/playout/playlist'
2526
2627/**
2728 * Load a PlayoutModelPreInit for the given RundownPlaylist
@@ -59,7 +60,7 @@ export async function loadPlayoutModelPreInit(
5960 peripheralDevices : PeripheralDevices ,
6061
6162 playlist : Playlist ,
62- rundowns : Rundowns ,
63+ rundowns : sortRundownsWithinPlaylist ( Playlist . rundownIdsInOrder , Rundowns ) ,
6364
6465 getRundown : ( id : RundownId ) => Rundowns . find ( ( rd ) => rd . _id === id ) ,
6566 }
You can’t perform that action at this time.
0 commit comments