1- import { useEffect } from 'react'
1+ import React , { useEffect } from 'react'
22import Moment from 'react-moment'
33import { useTranslation } from 'react-i18next'
4- import { WithTiming , withTiming } from '../RundownView/RundownTiming/withTiming.js'
5- import { withTracker } from '../../lib/ReactMeteorData/ReactMeteorData.js'
4+ import { useTiming } from '../RundownView/RundownTiming/withTiming.js'
5+ import { useTracker } from '../../lib/ReactMeteorData/ReactMeteorData.js'
66import { PieceIconContainer } from '../PieceIcons/PieceIcon.js'
77import { PieceNameContainer } from '../PieceIcons/PieceName.js'
88import { Timediff } from './Timediff.js'
9- import {
10- getPresenterScreenReactive ,
11- PresenterScreenTrackedProps ,
12- usePresenterScreenSubscriptions ,
13- } from './PresenterScreen.js'
9+ import { getPresenterScreenReactive , usePresenterScreenSubscriptions } from './PresenterScreen.js'
1410import { RundownPlaylistId , StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids'
1511
1612interface TimeMap {
@@ -22,75 +18,62 @@ interface OverlayScreenProps {
2218 playlistId : RundownPlaylistId
2319 segmentLiveDurations ?: TimeMap
2420}
25- interface OverlayScreenState { }
2621
2722/**
2823 * This component renders a Countdown screen for a given playlist
2924 */
30- export const OverlayScreen = withTracker < OverlayScreenProps , OverlayScreenState , PresenterScreenTrackedProps > (
31- getPresenterScreenReactive
32- ) (
33- withTiming < OverlayScreenProps & PresenterScreenTrackedProps , OverlayScreenState > ( ) ( function OverlayScreen (
34- props : Readonly < WithTiming < OverlayScreenProps & PresenterScreenTrackedProps > >
35- ) {
36- usePresenterScreenSubscriptions ( props )
37-
38- useEffect ( ( ) => {
39- const bodyClassList : string [ ] = [ 'transparent' ]
40-
41- document . body . classList . add ( ...bodyClassList )
42-
43- return ( ) => {
44- document . body . classList . remove ( ...bodyClassList )
45- }
46- } , [ ] )
47-
48- return < OverlayScreenContent { ...props } />
49- } )
50- )
51-
52- function OverlayScreenContent ( {
53- playlist,
54- segments,
55- nextShowStyleBaseId,
56- playlistId,
57- currentPartInstance,
58- nextPartInstance,
59- timingDurations,
60- rundownIds,
61- } : Readonly < WithTiming < OverlayScreenProps & PresenterScreenTrackedProps > > ) {
25+ export function OverlayScreen ( { playlistId, studioId } : OverlayScreenProps ) : React . JSX . Element {
6226 const { t } = useTranslation ( )
6327
64- if ( playlist && playlistId && segments ) {
65- const currentPart = currentPartInstance
28+ usePresenterScreenSubscriptions ( { playlistId, studioId } )
6629
67- let currentPartCountdown : number | null = null
68- if ( currentPart ) {
69- currentPartCountdown = timingDurations . remainingTimeOnCurrentPart || 0
70- }
30+ const presenterScreenProps = useTracker (
31+ ( ) => getPresenterScreenReactive ( studioId , playlistId ) ,
32+ [ studioId , playlistId ]
33+ )
34+
35+ const timing = useTiming ( )
7136
72- const nextPart = nextPartInstance
37+ useEffect ( ( ) => {
38+ const bodyClassList : string [ ] = [ 'transparent' ]
7339
74- // The over-under counter is something we may want to introduce into the screen at some point,
75- // So I'm leaving these as a reference -- Jan Starzak, 2020/12/16
76- // const overUnderClock = playlist.expectedDuration
77- // ? (this.props.timingDurations.asPlayedRundownDuration || 0) - playlist.expectedDuration
78- // : (this.props.timingDurations.asPlayedRundownDuration || 0) -
79- // (this.props.timingDurations.totalRundownDuration || 0)
40+ document . body . classList . add ( ...bodyClassList )
8041
81- const currentTime = timingDurations . currentTime || 0
42+ return ( ) => {
43+ document . body . classList . remove ( ...bodyClassList )
44+ }
45+ } , [ ] )
8246
47+ if ( ! presenterScreenProps ?. playlist || ! playlistId || ! presenterScreenProps ?. segments ) {
8348 return (
8449 < div className = "clocks-overlay" >
85- < div className = "clocks-lower-third bottom" >
86- < div className = "clocks-current-segment-countdown clocks-segment-countdown" >
87- { currentPartCountdown !== null ? (
88- < Timediff time = { currentPartCountdown } />
89- ) : (
90- < span className = "clock-segment-countdown-next" > { t ( 'Next' ) } </ span >
91- ) }
92- </ div >
93- { /*
50+ < div className = "clocks-lower-third bottom" > </ div >
51+ </ div >
52+ )
53+ }
54+
55+ const currentPart = presenterScreenProps ?. currentPartInstance
56+
57+ let currentPartCountdown : number | null = null
58+ if ( currentPart ) {
59+ currentPartCountdown = timing . remainingTimeOnCurrentPart || 0
60+ }
61+
62+ const nextPart = presenterScreenProps ?. nextPartInstance
63+
64+ const currentTime = timing . currentTime || 0
65+
66+ return (
67+ < div className = "clocks-overlay" >
68+ < div className = "clocks-lower-third bottom" >
69+ < div className = "clocks-current-segment-countdown clocks-segment-countdown" >
70+ { currentPartCountdown !== null ? (
71+ < Timediff time = { currentPartCountdown } />
72+ ) : (
73+ < span className = "clock-segment-countdown-next" > { t ( 'Next' ) } </ span >
74+ ) }
75+ </ div >
76+ { /*
9477 // An Auto-Next is something we may want to introduce in this view after we have
9578 // some feedback from the users and they say it may be useful.
9679 // -- Jan Starzak, 2020/12/16
@@ -100,39 +83,33 @@ function OverlayScreenContent({
10083 <img style={{ height: '0.5em', verticalAlign: 'top' }} src="/icons/auto-presenter-screen.svg" />
10184 </div>
10285 ) : null} */ }
103- < div className = "clocks-part-icon" >
104- { nextPart && nextShowStyleBaseId ? (
105- < PieceIconContainer
106- partInstanceId = { nextPart . instance . _id }
107- showStyleBaseId = { nextShowStyleBaseId }
108- rundownIds = { rundownIds }
109- playlistActivationId = { playlist ?. activationId }
110- />
111- ) : null }
112- </ div >
113- < div className = "clocks-part-title clocks-part-title" >
114- { nextPart && nextShowStyleBaseId && nextPart . instance . part . title ? (
115- < PieceNameContainer
116- partName = { nextPart . instance . part . title }
117- partInstanceId = { nextPart . instance . _id }
118- showStyleBaseId = { nextShowStyleBaseId }
119- rundownIds = { rundownIds }
120- playlistActivationId = { playlist ?. activationId }
121- />
122- ) : (
123- '_'
124- ) }
125- </ div >
126- < span className = "clocks-time-now" >
127- < Moment interval = { 0 } format = "HH:mm:ss" date = { currentTime } />
128- </ span >
86+ < div className = "clocks-part-icon" >
87+ { nextPart && presenterScreenProps ?. nextShowStyleBaseId ? (
88+ < PieceIconContainer
89+ partInstanceId = { nextPart . instance . _id }
90+ showStyleBaseId = { presenterScreenProps ?. nextShowStyleBaseId }
91+ rundownIds = { presenterScreenProps ?. rundownIds }
92+ playlistActivationId = { presenterScreenProps ?. playlist ?. activationId }
93+ />
94+ ) : null }
12995 </ div >
96+ < div className = "clocks-part-title clocks-part-title" >
97+ { nextPart && presenterScreenProps ?. nextShowStyleBaseId && nextPart . instance . part . title ? (
98+ < PieceNameContainer
99+ partName = { nextPart . instance . part . title }
100+ partInstanceId = { nextPart . instance . _id }
101+ showStyleBaseId = { presenterScreenProps ?. nextShowStyleBaseId }
102+ rundownIds = { presenterScreenProps ?. rundownIds }
103+ playlistActivationId = { presenterScreenProps ?. playlist ?. activationId }
104+ />
105+ ) : (
106+ '_'
107+ ) }
108+ </ div >
109+ < span className = "clocks-time-now" >
110+ < Moment interval = { 0 } format = "HH:mm:ss" date = { currentTime } />
111+ </ span >
130112 </ div >
131- )
132- }
133- return (
134- < div className = "clocks-overlay" >
135- < div className = "clocks-lower-third bottom" > </ div >
136113 </ div >
137114 )
138115}
0 commit comments