Skip to content

Commit 1a81bed

Browse files
committed
Merge branch 'release51'
2 parents ba69857 + ad370c1 commit 1a81bed

File tree

2 files changed

+24
-46
lines changed

2 files changed

+24
-46
lines changed

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

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { unprotectString, protectString } from '@sofie-automation/corelib/dist/p
1010
import { logger } from '../logging'
1111
import { PlayoutModel } from '../playout/model/PlayoutModel'
1212
import { PlayoutRundownModel } from '../playout/model/PlayoutRundownModel'
13-
import { isTooCloseToAutonext } from '../playout/lib'
1413
import { allowedToMoveRundownOutOfPlaylist } from '../rundown'
1514
import { updatePartInstanceRanksAndOrphanedState } from '../updatePartInstanceRanksAndOrphanedState'
1615
import {
@@ -224,8 +223,6 @@ export async function CommitIngestOperation(
224223
const pSaveIngest = ingestModel.saveAllToDatabase()
225224
pSaveIngest.catch(() => null) // Ensure promise isn't reported as unhandled
226225

227-
ensureNextPartInstanceIsNotDeleted(playoutModel)
228-
229226
await validateAdlibTestingSegment(context, playoutModel)
230227

231228
try {
@@ -284,19 +281,9 @@ function canRemoveSegment(
284281
logger.warn(`Not allowing removal of current playing segment "${segmentId}", making segment unsynced instead`)
285282
return false
286283
}
287-
if (nextPartInstance?.segmentId === segmentId && isTooCloseToAutonext(currentPartInstance, false)) {
288-
// Don't allow removing an active rundown
289-
logger.warn(
290-
`Not allowing removal of nexted segment "${segmentId}", because it's too close to an auto-next, making segment unsynced instead`
291-
)
292-
return false
293-
}
294-
295-
if (nextPartInstance?.segmentId === segmentId && nextPartInstance.orphaned === 'adlib-part') {
284+
if (nextPartInstance?.segmentId === segmentId) {
296285
// Don't allow removing an active rundown
297-
logger.warn(
298-
`Not allowing removal of segment "${segmentId}" which contains nexted adlibbed part, making segment unsynced instead`
299-
)
286+
logger.warn(`Not allowing removal of nexted segment "${segmentId}", making segment unsynced instead`)
300287
return false
301288
}
302289

@@ -855,12 +842,3 @@ async function validateAdlibTestingSegment(_context: JobContext, playoutModel: P
855842
rundown.updateAdlibTestingSegmentRank()
856843
}
857844
}
858-
function ensureNextPartInstanceIsNotDeleted(playoutModel: PlayoutModel) {
859-
if (playoutModel.nextPartInstance) {
860-
// Check if the segment of the nextPartInstance exists
861-
if (!playoutModel.findSegment(playoutModel.nextPartInstance.partInstance.segmentId)) {
862-
// The segment doesn't exist, set nextPartInstance to null, it'll be set by ensureNextPartIsValid() later.
863-
playoutModel.setPartInstanceAsNext(null, false, false)
864-
}
865-
}
866-
}

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,28 @@ export async function ensureNextPartIsValid(context: JobContext, playoutModel: P
4545
const orderedSegments = playoutModel.getAllOrderedSegments()
4646
const orderedParts = playoutModel.getAllOrderedParts()
4747

48-
if (currentPartInstance && nextPartInstance) {
48+
if (!nextPartInstance || nextPartInstance.partInstance.orphaned === 'deleted') {
49+
// Don't have a nextPart or it has been deleted, so autoselect something
50+
const newNextPart = selectNextPart(
51+
context,
52+
playlist,
53+
currentPartInstance?.partInstance ?? null,
54+
nextPartInstance?.partInstance ?? null,
55+
orderedSegments,
56+
orderedParts
57+
)
58+
59+
if (!newNextPart && !playoutModel.playlist.nextPartInfo) {
60+
// No currently nexted part, and nothing was selected, so nothing to update
61+
span?.end()
62+
return false
63+
}
64+
65+
await setNextPart(context, playoutModel, newNextPart ?? null, false)
66+
67+
span?.end()
68+
return true
69+
} else if (currentPartInstance && nextPartInstance) {
4970
// Check if the part is the same
5071
const newNextPart = selectNextPart(
5172
context,
@@ -70,27 +91,6 @@ export async function ensureNextPartIsValid(context: JobContext, playoutModel: P
7091
span?.end()
7192
return true
7293
}
73-
} else if (!nextPartInstance || nextPartInstance.partInstance.orphaned === 'deleted') {
74-
// Don't have a nextPart or it has been deleted, so autoselect something
75-
const newNextPart = selectNextPart(
76-
context,
77-
playlist,
78-
currentPartInstance?.partInstance ?? null,
79-
nextPartInstance?.partInstance ?? null,
80-
orderedSegments,
81-
orderedParts
82-
)
83-
84-
if (!newNextPart && !playoutModel.playlist.nextPartInfo) {
85-
// No currently nexted part, and nothing was selected, so nothing to update
86-
span?.end()
87-
return false
88-
}
89-
90-
await setNextPart(context, playoutModel, newNextPart ?? null, false)
91-
92-
span?.end()
93-
return true
9494
}
9595

9696
span?.end()

0 commit comments

Comments
 (0)