1
- import { useEffect } from 'react'
1
+ import React , { useEffect } from 'react'
2
2
import Moment from 'react-moment'
3
3
import { 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'
6
6
import { PieceIconContainer } from '../PieceIcons/PieceIcon.js'
7
7
import { PieceNameContainer } from '../PieceIcons/PieceName.js'
8
8
import { Timediff } from './Timediff.js'
9
- import {
10
- getPresenterScreenReactive ,
11
- PresenterScreenTrackedProps ,
12
- usePresenterScreenSubscriptions ,
13
- } from './PresenterScreen.js'
9
+ import { getPresenterScreenReactive , usePresenterScreenSubscriptions } from './PresenterScreen.js'
14
10
import { RundownPlaylistId , StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids'
15
11
16
12
interface TimeMap {
@@ -22,75 +18,62 @@ interface OverlayScreenProps {
22
18
playlistId : RundownPlaylistId
23
19
segmentLiveDurations ?: TimeMap
24
20
}
25
- interface OverlayScreenState { }
26
21
27
22
/**
28
23
* This component renders a Countdown screen for a given playlist
29
24
*/
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 {
62
26
const { t } = useTranslation ( )
63
27
64
- if ( playlist && playlistId && segments ) {
65
- const currentPart = currentPartInstance
28
+ usePresenterScreenSubscriptions ( { playlistId, studioId } )
66
29
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 ( )
71
36
72
- const nextPart = nextPartInstance
37
+ useEffect ( ( ) => {
38
+ const bodyClassList : string [ ] = [ 'transparent' ]
73
39
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 )
80
41
81
- const currentTime = timingDurations . currentTime || 0
42
+ return ( ) => {
43
+ document . body . classList . remove ( ...bodyClassList )
44
+ }
45
+ } , [ ] )
82
46
47
+ if ( ! presenterScreenProps ?. playlist || ! playlistId || ! presenterScreenProps ?. segments ) {
83
48
return (
84
49
< 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
+ { /*
94
77
// An Auto-Next is something we may want to introduce in this view after we have
95
78
// some feedback from the users and they say it may be useful.
96
79
// -- Jan Starzak, 2020/12/16
@@ -100,39 +83,33 @@ function OverlayScreenContent({
100
83
<img style={{ height: '0.5em', verticalAlign: 'top' }} src="/icons/auto-presenter-screen.svg" />
101
84
</div>
102
85
) : 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 }
129
95
</ 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 >
130
112
</ div >
131
- )
132
- }
133
- return (
134
- < div className = "clocks-overlay" >
135
- < div className = "clocks-lower-third bottom" > </ div >
136
113
</ div >
137
114
)
138
115
}
0 commit comments