Skip to content

Commit

Permalink
fix(updateNext): do the flow for no nextPartInstance or oprhaned === …
Browse files Browse the repository at this point in the history
…'deleted' first
  • Loading branch information
jstarpl committed Jan 14, 2025
1 parent 74136f1 commit b480cc8
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions packages/job-worker/src/ingest/updateNext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down

0 comments on commit b480cc8

Please sign in to comment.