@@ -45,7 +45,28 @@ export async function ensureNextPartIsValid(context: JobContext, playoutModel: P
45
45
const orderedSegments = playoutModel . getAllOrderedSegments ( )
46
46
const orderedParts = playoutModel . getAllOrderedParts ( )
47
47
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 ) {
49
70
// Check if the part is the same
50
71
const newNextPart = selectNextPart (
51
72
context ,
@@ -70,27 +91,6 @@ export async function ensureNextPartIsValid(context: JobContext, playoutModel: P
70
91
span ?. end ( )
71
92
return true
72
93
}
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
94
94
}
95
95
96
96
span ?. end ( )
0 commit comments