diff --git a/packages/job-worker/src/ingest/commit.ts b/packages/job-worker/src/ingest/commit.ts index c82f633430..79f72eb905 100644 --- a/packages/job-worker/src/ingest/commit.ts +++ b/packages/job-worker/src/ingest/commit.ts @@ -10,7 +10,6 @@ import { unprotectString, protectString } from '@sofie-automation/corelib/dist/p import { logger } from '../logging' import { PlayoutModel } from '../playout/model/PlayoutModel' import { PlayoutRundownModel } from '../playout/model/PlayoutRundownModel' -import { isTooCloseToAutonext } from '../playout/lib' import { allowedToMoveRundownOutOfPlaylist } from '../rundown' import { updatePartInstanceRanksAndOrphanedState } from '../updatePartInstanceRanksAndOrphanedState' import { @@ -224,8 +223,6 @@ export async function CommitIngestOperation( const pSaveIngest = ingestModel.saveAllToDatabase() pSaveIngest.catch(() => null) // Ensure promise isn't reported as unhandled - ensureNextPartInstanceIsNotDeleted(playoutModel) - await validateAdlibTestingSegment(context, playoutModel) try { @@ -284,19 +281,9 @@ function canRemoveSegment( logger.warn(`Not allowing removal of current playing segment "${segmentId}", making segment unsynced instead`) return false } - if (nextPartInstance?.segmentId === segmentId && isTooCloseToAutonext(currentPartInstance, false)) { - // Don't allow removing an active rundown - logger.warn( - `Not allowing removal of nexted segment "${segmentId}", because it's too close to an auto-next, making segment unsynced instead` - ) - return false - } - - if (nextPartInstance?.segmentId === segmentId && nextPartInstance.orphaned === 'adlib-part') { + if (nextPartInstance?.segmentId === segmentId) { // Don't allow removing an active rundown - logger.warn( - `Not allowing removal of segment "${segmentId}" which contains nexted adlibbed part, making segment unsynced instead` - ) + logger.warn(`Not allowing removal of nexted segment "${segmentId}", making segment unsynced instead`) return false } @@ -855,12 +842,3 @@ async function validateAdlibTestingSegment(_context: JobContext, playoutModel: P rundown.updateAdlibTestingSegmentRank() } } -function ensureNextPartInstanceIsNotDeleted(playoutModel: PlayoutModel) { - if (playoutModel.nextPartInstance) { - // Check if the segment of the nextPartInstance exists - if (!playoutModel.findSegment(playoutModel.nextPartInstance.partInstance.segmentId)) { - // The segment doesn't exist, set nextPartInstance to null, it'll be set by ensureNextPartIsValid() later. - playoutModel.setPartInstanceAsNext(null, false, false) - } - } -} diff --git a/packages/job-worker/src/ingest/updateNext.ts b/packages/job-worker/src/ingest/updateNext.ts index cc02774a9b..ce904e5bbe 100644 --- a/packages/job-worker/src/ingest/updateNext.ts +++ b/packages/job-worker/src/ingest/updateNext.ts @@ -45,7 +45,28 @@ export async function ensureNextPartIsValid(context: JobContext, playoutModel: P const orderedSegments = playoutModel.getAllOrderedSegments() const orderedParts = playoutModel.getAllOrderedParts() - if (currentPartInstance && nextPartInstance) { + if (!nextPartInstance || nextPartInstance.partInstance.orphaned === 'deleted') { + // Don't have a nextPart or it has been deleted, so autoselect something + const newNextPart = selectNextPart( + context, + playlist, + currentPartInstance?.partInstance ?? null, + nextPartInstance?.partInstance ?? null, + orderedSegments, + orderedParts + ) + + if (!newNextPart && !playoutModel.playlist.nextPartInfo) { + // No currently nexted part, and nothing was selected, so nothing to update + span?.end() + return false + } + + await setNextPart(context, playoutModel, newNextPart ?? null, false) + + span?.end() + return true + } else if (currentPartInstance && nextPartInstance) { // Check if the part is the same const newNextPart = selectNextPart( context, @@ -70,27 +91,6 @@ export async function ensureNextPartIsValid(context: JobContext, playoutModel: P span?.end() return true } - } else if (!nextPartInstance || nextPartInstance.partInstance.orphaned === 'deleted') { - // Don't have a nextPart or it has been deleted, so autoselect something - const newNextPart = selectNextPart( - context, - playlist, - currentPartInstance?.partInstance ?? null, - nextPartInstance?.partInstance ?? null, - orderedSegments, - orderedParts - ) - - if (!newNextPart && !playoutModel.playlist.nextPartInfo) { - // No currently nexted part, and nothing was selected, so nothing to update - span?.end() - return false - } - - await setNextPart(context, playoutModel, newNextPart ?? null, false) - - span?.end() - return true } span?.end()