Skip to content

Commit 94fd992

Browse files
authored
Merge pull request #1299 from nrkno/fix/sofie-3542/rundown-view-crash
2 parents eb0416e + 69ae70a commit 94fd992

File tree

4 files changed

+47
-49
lines changed

4 files changed

+47
-49
lines changed

meteor/client/ui/SegmentStoryboard/SegmentStoryboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ export const SegmentStoryboard = React.memo(
676676
>
677677
<div
678678
className={classNames('segment-storyboard__part-list', {
679-
loading: !props.subscriptionsReady /* */,
679+
loading: !props.subscriptionsReady,
680680
})}
681681
style={!animateScrollLeft ? { transform: `translateX(-${scrollLeft}px)` } : undefined}
682682
>
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react'
12
import { ISourceLayer, SourceLayerType } from '@sofie-automation/blueprints-integration'
23
import { PartId, PartInstanceId } from '@sofie-automation/corelib/dist/dataModel/Ids'
34
import { UIStudio } from '../../../../../lib/api/studios'
@@ -27,31 +28,32 @@ export interface IProps {
2728
isNext: boolean
2829
}
2930

30-
export default function renderThumbnail(props: Readonly<IProps>): JSX.Element {
31+
export const ThumbnailRenderer = React.memo(function ThumbnailRenderer(props: Readonly<IProps>): JSX.Element {
3132
const type = props.layer?.type
33+
3234
switch (type) {
3335
case SourceLayerType.VT:
3436
case SourceLayerType.LIVE_SPEAK:
35-
return VTThumbnailRenderer(props)
37+
return <VTThumbnailRenderer {...props} />
3638
case SourceLayerType.CAMERA:
3739
case SourceLayerType.REMOTE:
38-
return CameraThumbnailRenderer(props)
40+
return <CameraThumbnailRenderer {...props} />
3941
case SourceLayerType.SPLITS:
40-
return SplitsThumbnailRenderer(props)
42+
return <SplitsThumbnailRenderer {...props} />
4143
case SourceLayerType.GRAPHICS:
4244
case SourceLayerType.LOWER_THIRD:
4345
case SourceLayerType.STUDIO_SCREEN:
44-
return GraphicsThumbnailRenderer(props)
46+
return <GraphicsThumbnailRenderer {...props} />
4547
case SourceLayerType.LOCAL:
46-
return LocalThumbnailRenderer(props)
48+
return <LocalThumbnailRenderer {...props} />
4749
case SourceLayerType.AUDIO:
4850
case SourceLayerType.SCRIPT:
4951
case SourceLayerType.TRANSITION:
5052
case SourceLayerType.UNKNOWN:
5153
case undefined:
52-
return DefaultThumbnailRenderer(props)
54+
return <DefaultThumbnailRenderer {...props} />
5355
default:
5456
assertNever(type)
55-
return DefaultThumbnailRenderer(props)
57+
return <DefaultThumbnailRenderer {...props} />
5658
}
57-
}
59+
})

meteor/client/ui/SegmentStoryboard/StoryboardPartThumbnail/StoryboardPartThumbnail.tsx

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SourceLayerType } from '@sofie-automation/blueprints-integration'
22
import classNames from 'classnames'
3-
import React, { useEffect, useState } from 'react'
3+
import React, { useMemo, useState } from 'react'
44
import { PartExtended, PieceExtended } from '../../../lib/RundownResolver'
55
import { findPieceExtendedToShowFromOrderedResolvedInstances } from '../../PieceIcons/utils'
66
import StudioContext from '../../RundownView/StudioContext'
@@ -31,30 +31,27 @@ export const StoryboardPartThumbnail = React.memo(function StoryboardPartThumbna
3131
isLive,
3232
isNext,
3333
}: Readonly<IProps>) {
34-
const [mainPiece, setMainPiece] = useState<PieceExtended | undefined>(findMainPiece(part.pieces))
34+
const mainPiece = useMemo<PieceExtended | undefined>(() => findMainPiece(part.pieces), [part.pieces])
3535
const [highlight] = useState(false)
3636

37-
useEffect(() => {
38-
const newMainPiece = findMainPiece(part.pieces)
39-
setMainPiece(newMainPiece)
40-
}, [part.pieces])
41-
4237
return mainPiece ? (
4338
<StudioContext.Consumer>
44-
{(studio) => (
45-
<StoryboardPartThumbnailInner
46-
piece={mainPiece}
47-
isLive={isLive}
48-
isNext={isNext}
49-
layer={mainPiece?.sourceLayer}
50-
studio={studio}
51-
partId={part.partId}
52-
partInstanceId={part.instance._id}
53-
highlight={highlight}
54-
partAutoNext={part.instance.part.autoNext ?? false}
55-
partPlannedStoppedPlayback={part.instance.timings?.plannedStoppedPlayback}
56-
/>
57-
)}
39+
{(studio) =>
40+
studio ? (
41+
<StoryboardPartThumbnailInner
42+
piece={mainPiece}
43+
isLive={isLive}
44+
isNext={isNext}
45+
layer={mainPiece?.sourceLayer}
46+
studio={studio}
47+
partId={part.partId}
48+
partInstanceId={part.instance._id}
49+
highlight={highlight}
50+
partAutoNext={part.instance.part.autoNext ?? false}
51+
partPlannedStoppedPlayback={part.instance.timings?.plannedStoppedPlayback}
52+
/>
53+
) : null
54+
}
5855
</StudioContext.Consumer>
5956
) : (
6057
<div

meteor/client/ui/SegmentStoryboard/StoryboardPartThumbnail/StoryboardPartThumbnailInner.tsx

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ISourceLayer } from '@sofie-automation/blueprints-integration'
33
import { PieceExtended } from '../../../lib/RundownResolver'
44
import { getElementDocumentOffset, OffsetPosition } from '../../../utils/positions'
55
import { getElementHeight, getElementWidth } from '../../../utils/dimensions'
6-
import renderThumbnail from './Renderers/ThumbnailRendererFactory'
6+
import { ThumbnailRenderer } from './Renderers/ThumbnailRendererFactory'
77
import { PieceElement } from '../../SegmentContainer/PieceElement'
88
import { UIStudio } from '../../../../lib/api/studios'
99
import { PartId, PartInstanceId } from '@sofie-automation/corelib/dist/dataModel/Ids'
@@ -15,7 +15,7 @@ interface IProps {
1515
partPlannedStoppedPlayback: number | undefined
1616
layer: ISourceLayer | undefined
1717
piece: PieceExtended
18-
studio: UIStudio | undefined
18+
studio: UIStudio
1919
isLive: boolean
2020
isNext: boolean
2121
highlight?: boolean
@@ -87,22 +87,21 @@ export function StoryboardPartThumbnailInner({
8787
onPointerMove={onPointerMove}
8888
ref={thumbnailEl}
8989
>
90-
{studio &&
91-
renderThumbnail({
92-
partId,
93-
partInstanceId,
94-
partAutoNext,
95-
partPlannedStoppedPlayback,
96-
hoverScrubTimePosition: mousePosition * (piece.instance.piece.content.sourceDuration || 0),
97-
hovering: hover,
98-
layer: layer,
99-
height,
100-
originPosition: origin,
101-
pieceInstance: piece,
102-
studio,
103-
isLive,
104-
isNext,
105-
})}
90+
<ThumbnailRenderer
91+
partId={partId}
92+
partInstanceId={partInstanceId}
93+
partAutoNext={partAutoNext}
94+
partPlannedStoppedPlayback={partPlannedStoppedPlayback}
95+
hoverScrubTimePosition={mousePosition * (piece.instance.piece.content.sourceDuration || 0)}
96+
hovering={hover}
97+
layer={layer}
98+
height={height}
99+
originPosition={origin}
100+
pieceInstance={piece}
101+
studio={studio}
102+
isLive={isLive}
103+
isNext={isNext}
104+
/>
106105
</PieceElement>
107106
)
108107
}

0 commit comments

Comments
 (0)