Skip to content

Commit edc412f

Browse files
committed
wip
1 parent 6ace25b commit edc412f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

packages/job-worker/src/blueprints/context/SyncIngestUpdateToPartInstanceContext.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export class SyncIngestUpdateToPartInstanceContext
4040

4141
private partInstance: PlayoutPartInstanceModel | null
4242

43+
public get hasRemovedPartInstance(): boolean {
44+
return !this.partInstance
45+
}
46+
4347
constructor(
4448
private readonly _context: JobContext,
4549
contextInfo: ContextInfo,

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import { convertIngestModelToPlayoutRundownWithSegments } from './commit'
3333
import { convertNoteToNotification } from '../notifications/util'
3434
import { PlayoutRundownModel } from '../playout/model/PlayoutRundownModel'
3535
import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance'
36+
import { setNextPart, setNextPartFromPart } from '../playout/setNext'
37+
import { ensureNextPartIsValid } from './updateNext'
3638

3739
type PlayStatus = 'previous' | 'current' | 'next'
3840
type SyncedInstance = {
@@ -217,6 +219,30 @@ export async function syncChangesToPartInstances(
217219
existingPartInstance.snapshotRestore(partInstanceSnapshot)
218220
}
219221

222+
if (playStatus === 'next' && syncContext.hasRemovedPartInstance) {
223+
// PartInstance was removed, so we need to remove it and re-select the next part
224+
225+
if (playoutModel.playlist.nextPartInfo?.manuallySelected && newPart) {
226+
await setNextPart(
227+
context,
228+
playoutModel,
229+
{
230+
part: newPart,
231+
consumesQueuedSegmentId: playoutModel.playlist.nextPartInfo.consumesQueuedSegmentId,
232+
},
233+
true,
234+
playoutModel.playlist.nextTimeOffset || 0
235+
)
236+
} else {
237+
// Clear the next part
238+
await setNextPart(context, playoutModel, null, false, 0)
239+
await ensureNextPartIsValid(context, playoutModel)
240+
}
241+
242+
// We don't need to continue syncing this partInstance, as it's been replaced
243+
continue
244+
}
245+
220246
if (playStatus === 'next') {
221247
existingPartInstance.recalculateExpectedDurationWithTransition()
222248
}

0 commit comments

Comments
 (0)