Skip to content

Commit

Permalink
fix: handle a case in syncChangesToPartInstances()
Browse files Browse the repository at this point in the history
where the partInstance to be updated where in another rundown than the rundown in the provided context / playoutRundownModel
  • Loading branch information
nytamin committed Oct 24, 2024
1 parent 3fd22ef commit bf311c8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/job-worker/src/ingest/syncChangesToPartInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
import { validateAdlibTestingPartInstanceProperties } from '../playout/adlibTesting'
import { ReadonlyDeep } from 'type-fest'
import { convertIngestModelToPlayoutRundownWithSegments } from './commit'
import { PlayoutRundownModel } from '../playout/model/PlayoutRundownModel'

type PlayStatus = 'previous' | 'current' | 'next'
type SyncedInstance = {
Expand Down Expand Up @@ -132,12 +133,22 @@ export async function syncChangesToPartInstances(
pieceInstances: pieceInstancesInPart.map((p) => convertPieceInstanceToBlueprints(p.pieceInstance)),
}

const part = newPart ?? existingPartInstance.partInstance.part

let playoutRundownModelForPart: PlayoutRundownModel | undefined = playoutRundownModel
// Handle a case where the part is in a different rundown than the playoutRundownModel:
if (playoutRundownModel.rundown._id !== part.rundownId) {
playoutRundownModelForPart = playoutModel.getRundown(part.rundownId)
}
if (!playoutRundownModelForPart)
throw new Error(`Internal Error: playoutRundownModelForPart is undefined (it should never be)`)

const proposedPieceInstances = getPieceInstancesForPart(
context,
playoutModel,
previousPartInstance,
playoutRundownModel,
newPart ?? existingPartInstance.partInstance.part,
playoutRundownModelForPart,
part,
await piecesThatMayBeActive,
existingPartInstance.partInstance._id
)
Expand Down

0 comments on commit bf311c8

Please sign in to comment.