@@ -220,6 +220,7 @@ export async function fetchPiecesThatMayBeActiveForPart(
220220export async function syncPlayheadInfinitesForNextPartInstance (
221221 context : JobContext ,
222222 playoutModel : PlayoutModel ,
223+ unsavedIngestModel : Pick < IngestModelReadonly , 'rundownId' | 'getAllPieces' > | undefined ,
223224 fromPartInstance : PlayoutPartInstanceModel | null ,
224225 toPartInstance : PlayoutPartInstanceModel | null
225226) : Promise < void > {
@@ -293,6 +294,7 @@ export async function syncPlayheadInfinitesForNextPartInstance(
293294 const baselineInfinites = await getBaselineInfinitesForPart (
294295 context ,
295296 playoutModel ,
297+ unsavedIngestModel ,
296298 toPartInstance . partInstance . part ,
297299 toPartInstance . partInstance . _id
298300 )
@@ -403,17 +405,18 @@ export function getPieceInstancesForPart(
403405export async function getBaselineInfinitesForPart (
404406 context : JobContext ,
405407 playoutModel : PlayoutModel ,
406- // unsavedIngestModel: Pick<IngestModelReadonly, 'rundownId' | 'getAllPieces'> | undefined,
408+ unsavedIngestModel : Pick < IngestModelReadonly , 'rundownId' | 'getAllPieces' > | undefined ,
407409 part : ReadonlyDeep < DBPart > ,
408410 partInstanceId : PartInstanceId
409411) : Promise < PieceInstance [ ] > {
410- // nocommit - will this ever need to consider an unsaved ingest model?
411-
412- // Find the pieces
413- const pieces = await context . directCollections . Pieces . findFetch ( {
414- startRundownId : part . rundownId ,
415- startPartId : null ,
416- } )
412+ // Find the pieces. If an ingest model is provided, use that instead of the database
413+ const pieces =
414+ unsavedIngestModel && unsavedIngestModel . rundownId === part . rundownId
415+ ? unsavedIngestModel . getAllPieces ( ) . filter ( ( p ) => p . startPartId === null )
416+ : await context . directCollections . Pieces . findFetch ( {
417+ startRundownId : part . rundownId ,
418+ startPartId : null ,
419+ } )
417420
418421 const playlistActivationId = playoutModel . playlist . activationId
419422 if ( ! playlistActivationId ) throw new Error ( `RundownPlaylist "${ playoutModel . playlistId } " is not active` )
0 commit comments