Skip to content

Commit 010bf2c

Browse files
committed
fix: snapshot hook rundown lookup order
1 parent 9aba355 commit 010bf2c

1 file changed

Lines changed: 26 additions & 11 deletions

File tree

packages/job-worker/src/playout/snapshotHooks.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export async function invokeOnPlaylistSnapshotCreated(
7777
/**
7878
* Chooses which rundown (and thus show-style blueprint) to use for a playlist snapshot hook.
7979
*
80-
* Priority: next part instance → current part instance → first rundown sorted by name.
80+
* Prefer the next or current part’s rundown (from the playlist, then from part instances),
81+
* otherwise use the first rundown sorted by name.
8182
*/
8283
function pickRundownForPlaylistSnapshot(
8384
playlist: ReadonlyDeep<DBRundownPlaylist>,
@@ -88,22 +89,36 @@ function pickRundownForPlaylistSnapshot(
8889

8990
const partInstanceById = new Map(snapshot.partInstances.map((p) => [p._id, p]))
9091

91-
const nextPartInstanceId = playlist.nextPartInfo?.partInstanceId
92-
if (nextPartInstanceId) {
93-
const nextPartInstance = partInstanceById.get(nextPartInstanceId)
94-
if (nextPartInstance) {
95-
const rundown = rundowns.find((r) => r._id === nextPartInstance.rundownId)
92+
const nextPartInfo = playlist.nextPartInfo
93+
if (nextPartInfo) {
94+
if (nextPartInfo.rundownId) {
95+
const rundown = rundowns.find((r) => r._id === nextPartInfo.rundownId)
9696
if (rundown) return rundown
9797
}
98+
const nextPartInstanceId = nextPartInfo.partInstanceId
99+
if (nextPartInstanceId) {
100+
const nextPartInstance = partInstanceById.get(nextPartInstanceId)
101+
if (nextPartInstance) {
102+
const rundown = rundowns.find((r) => r._id === nextPartInstance.rundownId)
103+
if (rundown) return rundown
104+
}
105+
}
98106
}
99107

100-
const currentPartInstanceId = playlist.currentPartInfo?.partInstanceId
101-
if (currentPartInstanceId) {
102-
const currentPartInstance = partInstanceById.get(currentPartInstanceId)
103-
if (currentPartInstance) {
104-
const rundown = rundowns.find((r) => r._id === currentPartInstance.rundownId)
108+
const currentPartInfo = playlist.currentPartInfo
109+
if (currentPartInfo) {
110+
if (currentPartInfo.rundownId) {
111+
const rundown = rundowns.find((r) => r._id === currentPartInfo.rundownId)
105112
if (rundown) return rundown
106113
}
114+
const currentPartInstanceId = currentPartInfo.partInstanceId
115+
if (currentPartInstanceId) {
116+
const currentPartInstance = partInstanceById.get(currentPartInstanceId)
117+
if (currentPartInstance) {
118+
const rundown = rundowns.find((r) => r._id === currentPartInstance.rundownId)
119+
if (rundown) return rundown
120+
}
121+
}
107122
}
108123

109124
return rundowns[0]

0 commit comments

Comments
 (0)