@@ -3,13 +3,8 @@ import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
3
3
import { PartUi } from '../SegmentTimeline/SegmentTimelineContainer.js'
4
4
import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
5
5
import { Rundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
6
- import { withTiming , WithTiming } from '../RundownView/RundownTiming/withTiming.js'
7
- import {
8
- useSubscription ,
9
- useSubscriptions ,
10
- useTracker ,
11
- withTracker ,
12
- } from '../../lib/ReactMeteorData/ReactMeteorData.js'
6
+ import { useTiming } from '../RundownView/RundownTiming/withTiming.js'
7
+ import { useSubscription , useSubscriptions , useTracker } from '../../lib/ReactMeteorData/ReactMeteorData.js'
13
8
import { protectString , unprotectString } from '@sofie-automation/shared-lib/dist/lib/protectedString'
14
9
import { getCurrentTime } from '../../lib/systemTime.js'
15
10
import { PartInstance } from '@sofie-automation/meteor-lib/dist/collections/PartInstances'
@@ -36,7 +31,7 @@ import { RundownLayoutsAPI } from '../../lib/rundownLayouts.js'
36
31
import { ShelfDashboardLayout } from '../Shelf/ShelfDashboardLayout.js'
37
32
import { parse as queryStringParse } from 'query-string'
38
33
import { calculatePartInstanceExpectedDurationWithTransition } from '@sofie-automation/corelib/dist/playout/timings'
39
- import { getPlaylistTimingDiff } from '../../lib/rundownTiming.js'
34
+ import { getPlaylistTimingDiff , RundownTimingContext } from '../../lib/rundownTiming.js'
40
35
import { UIShowStyleBase } from '@sofie-automation/meteor-lib/dist/api/showStyles'
41
36
import { UIShowStyleBases , UIStudios } from '../Collections.js'
42
37
import { UIStudio } from '@sofie-automation/meteor-lib/dist/api/studios'
@@ -169,13 +164,16 @@ function getShowStyleBaseIdSegmentPartUi(
169
164
}
170
165
}
171
166
172
- export const getPresenterScreenReactive = ( props : PresenterScreenProps ) : PresenterScreenTrackedProps => {
173
- const studio = UIStudios . findOne ( props . studioId )
167
+ export const getPresenterScreenReactive = (
168
+ studioId : StudioId ,
169
+ playlistId : RundownPlaylistId
170
+ ) : PresenterScreenTrackedProps => {
171
+ const studio = UIStudios . findOne ( studioId )
174
172
175
173
let playlist : DBRundownPlaylist | undefined
176
174
177
- if ( props . playlistId )
178
- playlist = RundownPlaylists . findOne ( props . playlistId , {
175
+ if ( playlistId )
176
+ playlist = RundownPlaylists . findOne ( playlistId , {
179
177
fields : {
180
178
lastIncorrectPartPlaybackReported : 0 ,
181
179
modified : 0 ,
@@ -287,27 +285,41 @@ export const getPresenterScreenReactive = (props: PresenterScreenProps): Present
287
285
}
288
286
}
289
287
290
- function PresenterScreenContent ( props : WithTiming < PresenterScreenProps & PresenterScreenTrackedProps > ) : JSX . Element {
291
- usePresenterScreenSubscriptions ( props )
288
+ /**
289
+ * This component renders a Countdown screen for a given playlist
290
+ */
291
+ export function PresenterScreen ( { playlistId, studioId } : PresenterScreenProps ) : JSX . Element {
292
+ usePresenterScreenSubscriptions ( { playlistId, studioId } )
293
+
294
+ const presenterScreenProps = useTracker (
295
+ ( ) => getPresenterScreenReactive ( studioId , playlistId ) ,
296
+ [ studioId , playlistId ]
297
+ )
298
+
299
+ const timing = useTiming ( )
292
300
293
301
let selectedPresenterLayout : RundownLayoutBase | undefined = undefined
294
302
295
- if ( props . rundownLayouts ) {
303
+ if ( presenterScreenProps ? .rundownLayouts ) {
296
304
// first try to use the one selected by the user
297
- if ( props . presenterLayoutId ) {
298
- selectedPresenterLayout = props . rundownLayouts . find ( ( i ) => i . _id === props . presenterLayoutId )
305
+ if ( presenterScreenProps . presenterLayoutId ) {
306
+ selectedPresenterLayout = presenterScreenProps . rundownLayouts . find (
307
+ ( i ) => i . _id === presenterScreenProps . presenterLayoutId
308
+ )
299
309
}
300
310
301
311
// if couldn't find based on id, try matching part of the name
302
- if ( props . presenterLayoutId && ! selectedPresenterLayout ) {
303
- selectedPresenterLayout = props . rundownLayouts . find (
304
- ( i ) => i . name . indexOf ( unprotectString ( props . presenterLayoutId ! ) ) >= 0
312
+ if ( presenterScreenProps . presenterLayoutId && ! selectedPresenterLayout ) {
313
+ selectedPresenterLayout = presenterScreenProps . rundownLayouts . find (
314
+ ( i ) => i . name . indexOf ( unprotectString ( presenterScreenProps . presenterLayoutId ! ) ) >= 0
305
315
)
306
316
}
307
317
308
318
// if still not found, use the first one
309
319
if ( ! selectedPresenterLayout ) {
310
- selectedPresenterLayout = props . rundownLayouts . find ( ( i ) => RundownLayoutsAPI . isLayoutForPresenterView ( i ) )
320
+ selectedPresenterLayout = presenterScreenProps . rundownLayouts . find ( ( i ) =>
321
+ RundownLayoutsAPI . isLayoutForPresenterView ( i )
322
+ )
311
323
}
312
324
}
313
325
@@ -322,15 +334,37 @@ function PresenterScreenContent(props: WithTiming<PresenterScreenProps & Present
322
334
if ( presenterLayout && RundownLayoutsAPI . isDashboardLayout ( presenterLayout ) ) {
323
335
return (
324
336
< PresenterScreenContentDashboardLayout
325
- studio = { props . studio }
326
- playlist = { props . playlist }
327
- currentShowStyleBase = { props . currentShowStyleBase }
328
- currentShowStyleVariant = { props . currentShowStyleVariant }
337
+ studio = { presenterScreenProps ? .studio }
338
+ playlist = { presenterScreenProps ? .playlist }
339
+ currentShowStyleBase = { presenterScreenProps ? .currentShowStyleBase }
340
+ currentShowStyleVariant = { presenterScreenProps ? .currentShowStyleVariant }
329
341
layout = { presenterLayout }
330
342
/>
331
343
)
332
344
} else {
333
- return < PresenterScreenContentDefaultLayout { ...props } />
345
+ return (
346
+ < PresenterScreenContentDefaultLayout
347
+ playlist = { presenterScreenProps ?. playlist }
348
+ currentPartInstance = { presenterScreenProps ?. currentPartInstance }
349
+ nextPartInstance = { presenterScreenProps ?. nextPartInstance }
350
+ currentSegment = { presenterScreenProps ?. currentSegment }
351
+ currentShowStyleBaseId = { presenterScreenProps ?. currentShowStyleBaseId }
352
+ currentShowStyleBase = { presenterScreenProps ?. currentShowStyleBase }
353
+ currentShowStyleVariantId = { presenterScreenProps ?. currentShowStyleVariantId }
354
+ currentShowStyleVariant = { presenterScreenProps ?. currentShowStyleVariant }
355
+ nextSegment = { presenterScreenProps ?. nextSegment }
356
+ nextShowStyleBaseId = { presenterScreenProps ?. nextShowStyleBaseId }
357
+ playlistId = { playlistId }
358
+ presenterLayoutId = { presenterScreenProps ?. presenterLayoutId }
359
+ rundownIds = { presenterScreenProps ?. rundownIds ?? [ ] }
360
+ rundowns = { presenterScreenProps ?. rundowns ?? [ ] }
361
+ segments = { presenterScreenProps ?. segments ?? [ ] }
362
+ showStyleBaseIds = { presenterScreenProps ?. showStyleBaseIds ?? [ ] }
363
+ studio = { presenterScreenProps ?. studio }
364
+ studioId = { studioId }
365
+ timingDurations = { timing }
366
+ />
367
+ )
334
368
}
335
369
}
336
370
@@ -435,7 +469,7 @@ function PresenterScreenContentDefaultLayout({
435
469
nextPartInstance,
436
470
nextSegment,
437
471
rundownIds,
438
- } : Readonly < WithTiming < PresenterScreenProps & PresenterScreenTrackedProps > > ) {
472
+ } : Readonly < PresenterScreenProps & PresenterScreenTrackedProps & { timingDurations : RundownTimingContext } > ) {
439
473
if ( playlist && playlistId && segments ) {
440
474
const currentPartOrSegmentCountdown =
441
475
timingDurations . remainingBudgetOnCurrentSegment ?? timingDurations . remainingTimeOnCurrentPart ?? 0
@@ -560,10 +594,3 @@ function PresenterScreenContentDefaultLayout({
560
594
}
561
595
return null
562
596
}
563
-
564
- /**
565
- * This component renders a Countdown screen for a given playlist
566
- */
567
- export const PresenterScreen = withTracker < PresenterScreenProps , { } , PresenterScreenTrackedProps > (
568
- getPresenterScreenReactive
569
- ) ( withTiming < PresenterScreenProps & PresenterScreenTrackedProps , { } > ( ) ( PresenterScreenContent ) )
0 commit comments