Skip to content

Commit e8d6902

Browse files
committed
wip
1 parent 789e227 commit e8d6902

File tree

7 files changed

+24
-13
lines changed

7 files changed

+24
-13
lines changed

packages/corelib/src/playout/infinites.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ export function getPlayheadTrackingInfinitesForPart(
204204
case PieceLifespan.OutOnSegmentEnd:
205205
isValid =
206206
currentPartInstance.segmentId === intoPart.segmentId &&
207+
!!candidatePiece.piece.startPartId &&
207208
partsToReceiveOnSegmentEndFromSet.has(candidatePiece.piece.startPartId)
208209
break
209210
case PieceLifespan.OutOnRundownEnd:
@@ -294,11 +295,16 @@ export function isPiecePotentiallyActiveInPart(
294295
return false
295296
case PieceLifespan.OutOnSegmentEnd:
296297
return (
298+
!!pieceToCheck.startPartId &&
297299
pieceToCheck.startSegmentId === part.segmentId &&
298300
partsToReceiveOnSegmentEndFrom.has(pieceToCheck.startPartId)
299301
)
300302
case PieceLifespan.OutOnRundownEnd:
301-
if (pieceToCheck.startRundownId === part.rundownId) {
303+
if (
304+
pieceToCheck.startRundownId === part.rundownId &&
305+
pieceToCheck.startPartId &&
306+
pieceToCheck.startSegmentId
307+
) {
302308
if (pieceToCheck.startSegmentId === part.segmentId) {
303309
return partsToReceiveOnSegmentEndFrom.has(pieceToCheck.startPartId)
304310
} else {
@@ -315,6 +321,7 @@ export function isPiecePotentiallyActiveInPart(
315321
} else {
316322
// Predicting what will happen at arbitrary point in the future
317323
return (
324+
!!pieceToCheck.startPartId &&
318325
pieceToCheck.startSegmentId === part.segmentId &&
319326
partsToReceiveOnSegmentEndFrom.has(pieceToCheck.startPartId)
320327
)
@@ -327,6 +334,7 @@ export function isPiecePotentiallyActiveInPart(
327334
} else {
328335
// Predicting what will happen at arbitrary point in the future
329336
return (
337+
!!pieceToCheck.startSegmentId &&
330338
pieceToCheck.startRundownId === part.rundownId &&
331339
segmentsToReceiveOnRundownEndFrom.has(pieceToCheck.startSegmentId)
332340
)
@@ -389,8 +397,8 @@ export function getPieceInstancesForPart(
389397
if (pieceA.startPartId === pieceB.startPartId) {
390398
return pieceA.enable.start < pieceB.enable.start
391399
}
392-
const pieceAIndex = orderedPartIds.indexOf(pieceA.startPartId)
393-
const pieceBIndex = orderedPartIds.indexOf(pieceB.startPartId)
400+
const pieceAIndex = pieceA.startPartId === null ? -2 : orderedPartIds.indexOf(pieceA.startPartId)
401+
const pieceBIndex = pieceB.startPartId === null ? -2 : orderedPartIds.indexOf(pieceB.startPartId)
394402

395403
if (pieceAIndex === -1) {
396404
return false

packages/webui/src/client/lib/RundownResolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function fetchPiecesThatMayBeActiveForPart(
6262
segmentsToReceiveOnRundownEndFromSet: Set<SegmentId>,
6363
rundownsToReceiveOnShowStyleEndFrom: RundownId[],
6464
/** Map of Pieces on Parts, passed through for performance */
65-
allPiecesCache?: Map<PartId, Piece[]>
65+
allPiecesCache?: Map<PartId | null, Piece[]>
6666
): Piece[] {
6767
let piecesStartingInPart: Piece[]
6868
const allPieces = allPiecesCache?.get(part._id)
@@ -129,7 +129,7 @@ export function getPieceInstancesForPartInstance(
129129
currentSegment: Pick<DBSegment, '_id' | 'orphaned'> | undefined,
130130
currentPartInstancePieceInstances: PieceInstance[] | undefined,
131131
/** Map of Pieces on Parts, passed through for performance */
132-
allPiecesCache?: Map<PartId, Piece[]>,
132+
allPiecesCache?: Map<PartId | null, Piece[]>,
133133
options?: FindOptions<PieceInstance>,
134134
pieceInstanceSimulation?: boolean
135135
): PieceInstance[] {

packages/webui/src/client/lib/rundownPlaylistUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export class RundownPlaylistClientUtil {
164164
static getPiecesForParts(
165165
parts: Array<PartId>,
166166
piecesOptions?: Omit<FindOptions<Piece>, 'projection'> // We are mangling fields, so block projection
167-
): Map<PartId, Piece[]> {
167+
): Map<PartId | null, Piece[]> {
168168
const allPieces = Pieces.find(
169169
{ startPartId: { $in: parts } },
170170
{

packages/webui/src/client/ui/ClipTrimPanel/ClipTrimDialog.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export function ClipTrimDialog({
5656
const handleAccept = useCallback((e: SomeEvent) => {
5757
onClose?.()
5858

59+
const startPartId = selectedPiece.startPartId
60+
if (!startPartId) return
61+
5962
doUserAction(
6063
t,
6164
e,
@@ -65,7 +68,7 @@ export function ClipTrimDialog({
6568
e,
6669
ts,
6770
playlistId,
68-
selectedPiece.startPartId,
71+
startPartId,
6972
selectedPiece._id,
7073
state.inPoint,
7174
state.duration

packages/webui/src/client/ui/MediaStatus/MediaStatus.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,14 @@ function usePieceItems(partIds: PartId[], partMeta: Map<PartId, PartMeta>) {
458458
const pieceItems = useTracker(
459459
() =>
460460
pieces.map((piece) => {
461-
const meta = partMeta.get(piece.startPartId)
461+
const meta = piece.startPartId && partMeta.get(piece.startPartId)
462462

463463
if (!meta) return
464464
return getListItemFromPieceAndPartMeta(
465465
piece._id,
466466
piece,
467467
meta,
468-
piece.startPartId,
468+
piece.startPartId ?? undefined,
469469
undefined,
470470
meta.segmentId,
471471
false
@@ -499,15 +499,15 @@ function usePieceInstanceItems(partInstanceIds: PartInstanceId[], partInstanceMe
499499
const pieceInstanceItems = useTracker(
500500
() =>
501501
pieceInstances.map((pieceInstance) => {
502-
const meta = partInstanceMeta.get(pieceInstance.partInstanceId)
502+
const meta = pieceInstance.partInstanceId && partInstanceMeta.get(pieceInstance.partInstanceId)
503503

504504
if (!meta) return
505505
return getListItemFromPieceAndPartMeta(
506506
pieceInstance._id,
507507
pieceInstance.piece,
508508
meta,
509509
undefined,
510-
pieceInstance.partInstanceId,
510+
pieceInstance.partInstanceId ?? undefined,
511511
meta.segmentId,
512512
false
513513
)

packages/webui/src/client/ui/Prompter/prompter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export namespace PrompterAPI {
146146
let previousRundown: Rundown | null = null
147147
const rundownIds = rundowns.map((rundown) => rundown._id)
148148

149-
const allPiecesCache = new Map<PartId, Piece[]>()
149+
const allPiecesCache = new Map<PartId | null, Piece[]>()
150150
Pieces.find({
151151
startRundownId: { $in: rundownIds },
152152
}).forEach((piece) => {

packages/webui/src/client/ui/RundownView/SelectedElementsContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export function useSelectedElements(
221221
const computation = Tracker.nonreactive(() =>
222222
Tracker.autorun(() => {
223223
const piece = Pieces.findOne(selectedElement?.elementId)
224-
const part = UIParts.findOne({ _id: piece ? piece.startPartId : selectedElement?.elementId })
224+
const part = UIParts.findOne({ _id: piece?.startPartId ? piece.startPartId : selectedElement?.elementId })
225225
const segment = Segments.findOne({ _id: part ? part.segmentId : selectedElement?.elementId })
226226

227227
setPiece(piece)

0 commit comments

Comments
 (0)