@@ -3,13 +3,8 @@ import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
33import { PartUi } from '../SegmentTimeline/SegmentTimelineContainer.js'
44import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
55import { 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'
138import { protectString , unprotectString } from '@sofie-automation/shared-lib/dist/lib/protectedString'
149import { getCurrentTime } from '../../lib/systemTime.js'
1510import { PartInstance } from '@sofie-automation/meteor-lib/dist/collections/PartInstances'
@@ -36,7 +31,7 @@ import { RundownLayoutsAPI } from '../../lib/rundownLayouts.js'
3631import { ShelfDashboardLayout } from '../Shelf/ShelfDashboardLayout.js'
3732import { parse as queryStringParse } from 'query-string'
3833import { calculatePartInstanceExpectedDurationWithTransition } from '@sofie-automation/corelib/dist/playout/timings'
39- import { getPlaylistTimingDiff } from '../../lib/rundownTiming.js'
34+ import { getPlaylistTimingDiff , RundownTimingContext } from '../../lib/rundownTiming.js'
4035import { UIShowStyleBase } from '@sofie-automation/meteor-lib/dist/api/showStyles'
4136import { UIShowStyleBases , UIStudios } from '../Collections.js'
4237import { UIStudio } from '@sofie-automation/meteor-lib/dist/api/studios'
@@ -169,13 +164,16 @@ function getShowStyleBaseIdSegmentPartUi(
169164 }
170165}
171166
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 )
174172
175173 let playlist : DBRundownPlaylist | undefined
176174
177- if ( props . playlistId )
178- playlist = RundownPlaylists . findOne ( props . playlistId , {
175+ if ( playlistId )
176+ playlist = RundownPlaylists . findOne ( playlistId , {
179177 fields : {
180178 lastIncorrectPartPlaybackReported : 0 ,
181179 modified : 0 ,
@@ -287,27 +285,41 @@ export const getPresenterScreenReactive = (props: PresenterScreenProps): Present
287285 }
288286}
289287
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 ( )
292300
293301 let selectedPresenterLayout : RundownLayoutBase | undefined = undefined
294302
295- if ( props . rundownLayouts ) {
303+ if ( presenterScreenProps ? .rundownLayouts ) {
296304 // 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+ )
299309 }
300310
301311 // 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
305315 )
306316 }
307317
308318 // if still not found, use the first one
309319 if ( ! selectedPresenterLayout ) {
310- selectedPresenterLayout = props . rundownLayouts . find ( ( i ) => RundownLayoutsAPI . isLayoutForPresenterView ( i ) )
320+ selectedPresenterLayout = presenterScreenProps . rundownLayouts . find ( ( i ) =>
321+ RundownLayoutsAPI . isLayoutForPresenterView ( i )
322+ )
311323 }
312324 }
313325
@@ -322,15 +334,37 @@ function PresenterScreenContent(props: WithTiming<PresenterScreenProps & Present
322334 if ( presenterLayout && RundownLayoutsAPI . isDashboardLayout ( presenterLayout ) ) {
323335 return (
324336 < 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 }
329341 layout = { presenterLayout }
330342 />
331343 )
332344 } 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+ )
334368 }
335369}
336370
@@ -435,7 +469,7 @@ function PresenterScreenContentDefaultLayout({
435469 nextPartInstance,
436470 nextSegment,
437471 rundownIds,
438- } : Readonly < WithTiming < PresenterScreenProps & PresenterScreenTrackedProps > > ) {
472+ } : Readonly < PresenterScreenProps & PresenterScreenTrackedProps & { timingDurations : RundownTimingContext } > ) {
439473 if ( playlist && playlistId && segments ) {
440474 const currentPartOrSegmentCountdown =
441475 timingDurations . remainingBudgetOnCurrentSegment ?? timingDurations . remainingTimeOnCurrentPart ?? 0
@@ -560,10 +594,3 @@ function PresenterScreenContentDefaultLayout({
560594 }
561595 return null
562596}
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