Skip to content

Commit 87b2fa6

Browse files
Mint de Witrjmunro
authored andcommitted
chore: refactor SourceLayerItem component
1 parent b3332d4 commit 87b2fa6

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

packages/webui/src/client/ui/SegmentTimeline/SourceLayerItem.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,16 @@ export const SourceLayerItem = (props: Readonly<ISourceLayerItemProps>): JSX.Ele
164164
)
165165
const itemDblClick = useCallback(
166166
(e: React.MouseEvent<HTMLDivElement>) => {
167+
e.preventDefault()
168+
e.stopPropagation()
169+
167170
if (studio?.settings.enableUserEdits && !studio?.settings.allowPieceDirectPlay) {
168171
const pieceId = piece.instance.piece._id
169172
if (!selectElementContext.isSelected(pieceId)) {
170173
selectElementContext.clearAndSetSelection({ type: 'piece', elementId: pieceId })
171174
} else {
172175
selectElementContext.clearSelections()
173176
}
174-
// Until a proper data structure, the only reference is a part.
175-
// const partId = this.props.part.instance.part._id
176-
// if (!selectElementContext.isSelected(partId)) {
177-
// selectElementContext.clearAndSetSelection({ type: 'part', elementId: partId })
178-
// } else {
179-
// selectElementContext.clearSelections()
180-
// }
181177
} else if (typeof onDoubleClick === 'function') {
182178
onDoubleClick(piece, e)
183179
}
@@ -531,29 +527,31 @@ export const SourceLayerItem = (props: Readonly<ISourceLayerItemProps>): JSX.Ele
531527
...props,
532528
...state,
533529
}
530+
// Key cannot be part of a spread operator, therefore needs to be kept out of elProps
531+
const elKey = unprotectString(piece.instance._id)
534532

535533
switch (layer.type) {
536534
case SourceLayerType.SCRIPT:
537535
// case SourceLayerType.MIC:
538-
return <MicSourceRenderer key={unprotectString(piece.instance._id)} {...elProps} />
536+
return <MicSourceRenderer key={elKey} {...elProps} />
539537
case SourceLayerType.VT:
540538
case SourceLayerType.LIVE_SPEAK:
541-
return <VTSourceRenderer key={unprotectString(piece.instance._id)} {...elProps} />
539+
return <VTSourceRenderer key={elKey} {...elProps} />
542540
case SourceLayerType.GRAPHICS:
543541
case SourceLayerType.LOWER_THIRD:
544542
case SourceLayerType.STUDIO_SCREEN:
545-
return <L3rdSourceRenderer key={unprotectString(piece.instance._id)} {...elProps} />
543+
return <L3rdSourceRenderer key={elKey} {...elProps} />
546544
case SourceLayerType.SPLITS:
547-
return <SplitsSourceRenderer key={unprotectString(piece.instance._id)} {...elProps} />
545+
return <SplitsSourceRenderer key={elKey} {...elProps} />
548546

549547
case SourceLayerType.TRANSITION:
550548
// TODOSYNC: TV2 uses other renderers, to be discussed.
551549

552-
return <TransitionSourceRenderer key={unprotectString(piece.instance._id)} {...elProps} />
550+
return <TransitionSourceRenderer key={elKey} {...elProps} />
553551
case SourceLayerType.LOCAL:
554-
return <LocalLayerItemRenderer key={unprotectString(piece.instance._id)} {...elProps} />
552+
return <LocalLayerItemRenderer key={elKey} {...elProps} />
555553
default:
556-
return <DefaultLayerItemRenderer key={unprotectString(piece.instance._id)} {...elProps} />
554+
return <DefaultLayerItemRenderer key={elKey} {...elProps} />
557555
}
558556
}
559557

0 commit comments

Comments
 (0)