Skip to content

Commit eb0416e

Browse files
authored
Merge pull request Sofie-Automation#1302 from nrkno/fix/ingest-error
2 parents 67b3a96 + bf311c8 commit eb0416e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/job-worker/src/ingest/syncChangesToPartInstance.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
import { validateAdlibTestingPartInstanceProperties } from '../playout/adlibTesting'
3333
import { ReadonlyDeep } from 'type-fest'
3434
import { convertIngestModelToPlayoutRundownWithSegments } from './commit'
35+
import { PlayoutRundownModel } from '../playout/model/PlayoutRundownModel'
3536

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

136+
const part = newPart ?? existingPartInstance.partInstance.part
137+
138+
let playoutRundownModelForPart: PlayoutRundownModel | undefined = playoutRundownModel
139+
// Handle a case where the part is in a different rundown than the playoutRundownModel:
140+
if (playoutRundownModel.rundown._id !== part.rundownId) {
141+
playoutRundownModelForPart = playoutModel.getRundown(part.rundownId)
142+
}
143+
if (!playoutRundownModelForPart)
144+
throw new Error(`Internal Error: playoutRundownModelForPart is undefined (it should never be)`)
145+
135146
const proposedPieceInstances = getPieceInstancesForPart(
136147
context,
137148
playoutModel,
138149
previousPartInstance,
139-
playoutRundownModel,
140-
newPart ?? existingPartInstance.partInstance.part,
150+
playoutRundownModelForPart,
151+
part,
141152
await piecesThatMayBeActive,
142153
existingPartInstance.partInstance._id
143154
)

0 commit comments

Comments
 (0)