Skip to content

Commit a5e7af4

Browse files
Julusianjesperstarkar
authored andcommitted
fix: content status for PieceInstances can be under the id of the PieceInstance or the wrapped Piece SOFIE-2993
1 parent 1d0f8fc commit a5e7af4

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

meteor/client/ui/SegmentTimeline/withMediaObjectStatus.tsx

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,35 @@ export function withMediaObjectStatus<IProps extends AnyPiece, IState>(): (
7070
}
7171
}
7272

73+
private getStatusDocForPiece(
74+
piece: BucketAdLibUi | IAdLibListItem | AdLibPieceUi | PieceUi | BucketAdLibActionUi
75+
) {
76+
const pieceUnwrapped = WithMediaObjectStatusHOCComponent.unwrapPieceInstance(piece)
77+
78+
// Bucket items use a different collection
79+
if (RundownUtils.isBucketAdLibItem(piece)) {
80+
return UIBucketContentStatuses.findOne({
81+
bucketId: piece.bucketId,
82+
docId: pieceUnwrapped._id,
83+
})
84+
}
85+
86+
// PieceInstance's might have a dedicated status
87+
if (RundownUtils.isPieceInstance(piece)) {
88+
const status = UIPieceContentStatuses.findOne({
89+
// Future: It would be good for this to be stricter.
90+
pieceId: piece.instance._id,
91+
})
92+
if (status) return status
93+
}
94+
95+
// Fallback to using the one from the source piece
96+
return UIPieceContentStatuses.findOne({
97+
// Future: It would be good for this to be stricter.
98+
pieceId: pieceUnwrapped._id,
99+
})
100+
}
101+
73102
updateDataTracker() {
74103
if (this.destroyed) return
75104

@@ -80,19 +109,8 @@ export function withMediaObjectStatus<IProps extends AnyPiece, IState>(): (
80109

81110
// Check item status
82111
if (piece && (piece.sourceLayer || layer) && studio) {
83-
const pieceUnwrapped = WithMediaObjectStatusHOCComponent.unwrapPieceInstance(piece)
84-
const statusDoc = RundownUtils.isBucketAdLibItem(piece)
85-
? UIBucketContentStatuses.findOne({
86-
bucketId: piece.bucketId,
87-
docId: pieceUnwrapped._id,
88-
})
89-
: UIPieceContentStatuses.findOne({
90-
// Future: It would be good for this to be stricter.
91-
pieceId: pieceUnwrapped._id,
92-
})
93-
94112
// Extract the status or populate some default values
95-
const statusObj = statusDoc?.status ?? DEFAULT_STATUS
113+
const statusObj = this.getStatusDocForPiece(piece)?.status ?? DEFAULT_STATUS
96114

97115
if (RundownUtils.isAdLibPieceOrAdLibListItem(piece)) {
98116
if (!overrides.piece || !_.isEqual(statusObj, (overrides.piece as AdLibPieceUi).contentStatus)) {

0 commit comments

Comments
 (0)