Skip to content

Commit 2ad9eb9

Browse files
committed
Merge remote-tracking branch 'origin/release51' into release51
2 parents 3eb0f4a + 2f513b8 commit 2ad9eb9

File tree

3 files changed

+39
-23
lines changed

3 files changed

+39
-23
lines changed

packages/live-status-gateway/src/collections/partInstancesHandler.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,25 @@ export class PartInstancesHandler
138138
void this.changed(id, 'removed').catch(this._logger.error)
139139
}
140140

141-
const hasAnythingChanged = this.updateCollectionData()
142-
if (hasAnythingChanged) {
143-
await this.notify(this._collectionData)
144-
}
141+
await this.updateAndNotify()
145142
} else if (this._subscriptionId) {
146-
// nothing relevant has changed
143+
await this.updateAndNotify()
147144
} else {
148-
this.clearCollectionData()
149-
await this.notify(this._collectionData)
145+
await this.clearAndNotify()
150146
}
151147
} else {
152-
this.clearCollectionData()
148+
await this.clearAndNotify()
149+
}
150+
}
151+
152+
private async clearAndNotify() {
153+
this.clearCollectionData()
154+
await this.notify(this._collectionData)
155+
}
156+
157+
private async updateAndNotify() {
158+
const hasAnythingChanged = this.updateCollectionData()
159+
if (hasAnythingChanged) {
153160
await this.notify(this._collectionData)
154161
}
155162
}

packages/live-status-gateway/src/collections/pieceInstancesHandler.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,13 @@ export class PieceInstancesHandler
8282
}
8383
if (
8484
!areElementsShallowEqual(this._collectionData.currentPartInstance, inCurrentPartInstance) &&
85-
this._collectionData.currentPartInstance.some((pieceInstance, index) => {
86-
return !arePropertiesShallowEqual<PieceInstance>(inCurrentPartInstance[index], pieceInstance, [
87-
'reportedStartedPlayback',
88-
'reportedStoppedPlayback',
89-
])
90-
})
85+
(this._collectionData.currentPartInstance.length !== inCurrentPartInstance.length ||
86+
this._collectionData.currentPartInstance.some((pieceInstance, index) => {
87+
return !arePropertiesShallowEqual<PieceInstance>(inCurrentPartInstance[index], pieceInstance, [
88+
'reportedStartedPlayback',
89+
'reportedStoppedPlayback',
90+
])
91+
}))
9192
) {
9293
this._collectionData.currentPartInstance = inCurrentPartInstance
9394
hasAnythingChanged = true
@@ -153,22 +154,30 @@ export class PieceInstancesHandler
153154
void this.changed(id, 'removed').catch(this._logger.error)
154155
}
155156

156-
const hasAnythingChanged = this.updateCollectionData()
157-
if (hasAnythingChanged) {
158-
await this.notify(this._collectionData)
159-
}
157+
await this.updateAndNotify()
160158
} else if (this._subscriptionId) {
161-
// nothing relevant has changed
159+
await this.updateAndNotify()
162160
} else {
163-
this.clearCollectionData()
164-
await this.notify(this._collectionData)
161+
await this.clearAndNotify()
165162
}
166163
} else {
167164
this.clearCollectionData()
168165
await this.notify(this._collectionData)
169166
}
170167
}
171168

169+
private async clearAndNotify() {
170+
this.clearCollectionData()
171+
await this.notify(this._collectionData)
172+
}
173+
174+
private async updateAndNotify() {
175+
const hasAnythingChanged = this.updateCollectionData()
176+
if (hasAnythingChanged) {
177+
await this.notify(this._collectionData)
178+
}
179+
}
180+
172181
private isPieceInstanceActive(pieceInstance: PieceInstance) {
173182
return (
174183
pieceInstance.reportedStoppedPlayback == null &&
@@ -187,7 +196,7 @@ export function arePropertiesShallowEqual<T extends Record<string, any>>(
187196
b: T,
188197
omitProperties: Array<keyof T>
189198
): boolean {
190-
if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) {
199+
if (typeof a !== 'object' || a == null || typeof b !== 'object' || b == null) {
191200
return false
192201
}
193202

packages/live-status-gateway/src/topics/activePlaylistTopic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class ActivePlaylistTopic
134134
autoNext: nextPart.autoNext,
135135
segmentId: unprotectString(nextPart.segmentId),
136136
pieces:
137-
this._pieceInstancesInCurrentPartInstance?.map((piece) =>
137+
this._pieceInstancesInNextPartInstance?.map((piece) =>
138138
toPieceStatus(piece, this._showStyleBaseExt)
139139
) ?? [],
140140
publicData: nextPart.publicData,

0 commit comments

Comments
 (0)