11import ClassNames from 'classnames'
22import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
3- import { PartUi } from '../SegmentTimeline/SegmentTimelineContainer.js'
3+ import { PartUi } from '../../ SegmentTimeline/SegmentTimelineContainer.js'
44import { DBRundownPlaylist , ABSessionAssignment } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
55import { Rundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
6- import { useTiming } from '../RundownView/RundownTiming/withTiming.js'
76import {
87 useSubscription ,
98 useSubscriptions ,
109 useTracker ,
1110 withTracker ,
12- } from '../../lib/ReactMeteorData/ReactMeteorData.js'
13- import { getCurrentTime } from '../../lib/systemTime.js'
11+ } from '../../../ lib/ReactMeteorData/ReactMeteorData.js'
12+ import { getCurrentTime } from '../../../ lib/systemTime.js'
1413import { PartInstance } from '@sofie-automation/meteor-lib/dist/collections/PartInstances'
1514import { MeteorPubSub } from '@sofie-automation/meteor-lib/dist/api/pubsub'
16- import { PieceIconContainer } from './ClockViewPieceIcons/ClockViewPieceIcon.js'
17- import { PieceNameContainer } from './ClockViewPieceIcons/ClockViewPieceName.js'
18- import { Timediff } from './Timediff.js'
19- import { RundownUtils } from '../../lib/rundown.js'
15+ import { PieceIconContainer } from '.. /ClockViewPieceIcons/ClockViewPieceIcon.js'
16+ import { PieceNameContainer } from '.. /ClockViewPieceIcons/ClockViewPieceName.js'
17+ import { Timediff } from '.. /Timediff.js'
18+ import { RundownUtils } from '../../../ lib/rundown.js'
2019import { PieceLifespan , SourceLayerType } from '@sofie-automation/blueprints-integration'
2120import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part'
22- import { PieceFreezeContainer } from './ClockViewPieceIcons/ClockViewFreezeCount.js'
21+ import { PieceFreezeContainer } from '.. /ClockViewPieceIcons/ClockViewFreezeCount.js'
2322import { PlaylistTiming } from '@sofie-automation/corelib/dist/playout/rundownTiming'
2423import {
2524 RundownId ,
@@ -30,28 +29,24 @@ import {
3029} from '@sofie-automation/corelib/dist/dataModel/Ids'
3130import { DBShowStyleVariant } from '@sofie-automation/corelib/dist/dataModel/ShowStyleVariant'
3231import { calculatePartInstanceExpectedDurationWithTransition } from '@sofie-automation/corelib/dist/playout/timings'
33- import { getPlaylistTimingDiff } from '../../lib/rundownTiming.js'
3432import { UIShowStyleBase } from '@sofie-automation/meteor-lib/dist/api/showStyles'
35- import { UIShowStyleBases , UIStudios } from '../Collections.js'
33+ import { UIShowStyleBases , UIStudios } from '../../ Collections.js'
3634import { UIStudio } from '@sofie-automation/meteor-lib/dist/api/studios'
37- import { PieceInstances , RundownPlaylists , Rundowns , ShowStyleVariants } from '../../collections/index.js'
38- import { RundownPlaylistCollectionUtil } from '../../collections/rundownPlaylistUtil.js'
35+ import { PieceInstances , RundownPlaylists , Rundowns , ShowStyleVariants } from '../../../ collections/index.js'
36+ import { RundownPlaylistCollectionUtil } from '../../../ collections/rundownPlaylistUtil.js'
3937import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'
40- import { useSetDocumentClass } from '../util/useSetDocumentClass.js'
41- import { useRundownAndShowStyleIdsForPlaylist } from '../util/useRundownAndShowStyleIdsForPlaylist.js'
42- import { RundownPlaylistClientUtil } from '../../lib/rundownPlaylistUtil.js'
43- import { CurrentPartOrSegmentRemaining } from '../RundownView/RundownTiming/CurrentPartOrSegmentRemaining.js'
44- import {
45- OverUnderClockComponent ,
46- PlannedEndComponent ,
47- TimeSincePlannedEndComponent ,
48- TimeToPlannedEndComponent ,
49- } from '../../lib/Components/CounterComponents.js'
50- import { AdjustLabelFit } from '../util/AdjustLabelFit.js'
51- import { AutoNextStatus } from '../RundownView/RundownTiming/AutoNextStatus.js'
38+ import { useSetDocumentClass } from '../../util/useSetDocumentClass.js'
39+ import { useRundownAndShowStyleIdsForPlaylist } from '../../util/useRundownAndShowStyleIdsForPlaylist.js'
40+ import { RundownPlaylistClientUtil } from '../../../lib/rundownPlaylistUtil.js'
41+ import { CurrentPartOrSegmentRemaining } from '../../RundownView/RundownTiming/CurrentPartOrSegmentRemaining.js'
42+
43+ import { AdjustLabelFit } from '../../util/AdjustLabelFit.js'
44+ import { AutoNextStatus } from '../../RundownView/RundownTiming/AutoNextStatus.js'
5245import { useTranslation } from 'react-i18next'
5346import { DBShowStyleBase } from '@sofie-automation/corelib/dist/dataModel/ShowStyleBase'
5447import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance.js'
48+ import { DirectorScreenTop } from './DirectorScreenTop.js'
49+ import { useTiming } from '../../RundownView/RundownTiming/withTiming.js'
5550
5651interface SegmentUi extends DBSegment {
5752 items : Array < PartUi >
@@ -143,6 +138,7 @@ export interface DirectorScreenTrackedProps {
143138 nextShowStyleBaseId : ShowStyleBaseId | undefined
144139 showStyleBaseIds : ShowStyleBaseId [ ]
145140 rundownIds : RundownId [ ]
141+ partInstanceToCountTimeFrom : PartInstance | undefined
146142}
147143
148144function getShowStyleBaseIdSegmentPartUi (
@@ -248,6 +244,7 @@ const getDirectorScreenReactive = (props: DirectorScreenProps): DirectorScreenTr
248244 restoredFromSnapshotId : 0 ,
249245 } ,
250246 } )
247+
251248 const segments : Array < SegmentUi > = [ ]
252249 let showStyleBaseIds : ShowStyleBaseId [ ] = [ ]
253250 let rundowns : Rundown [ ] = [ ]
@@ -263,17 +260,24 @@ const getDirectorScreenReactive = (props: DirectorScreenProps): DirectorScreenTr
263260 let nextSegment : SegmentUi | undefined = undefined
264261 let nextPartInstanceUi : PartUi | undefined = undefined
265262 let nextShowStyleBaseId : ShowStyleBaseId | undefined = undefined
263+ let partInstanceToCountTimeFromUi : PartInstance | undefined = undefined
266264
267265 if ( playlist ) {
268266 rundowns = RundownPlaylistCollectionUtil . getRundownsOrdered ( playlist )
267+
269268 const orderedSegmentsAndParts = RundownPlaylistClientUtil . getSegmentsAndPartsSync ( playlist )
270269 rundownIds = rundowns . map ( ( rundown ) => rundown . _id )
271270 const rundownsToShowstyles : Map < RundownId , ShowStyleBaseId > = new Map ( )
272271 for ( const rundown of rundowns ) {
273272 rundownsToShowstyles . set ( rundown . _id , rundown . showStyleBaseId )
274273 }
274+
275275 showStyleBaseIds = rundowns . map ( ( rundown ) => rundown . showStyleBaseId )
276- const { currentPartInstance, nextPartInstance } = RundownPlaylistClientUtil . getSelectedPartInstances ( playlist )
276+ const { currentPartInstance, nextPartInstance, partInstanceToCountTimeFrom } =
277+ RundownPlaylistClientUtil . getSelectedPartInstances ( playlist )
278+
279+ partInstanceToCountTimeFromUi = partInstanceToCountTimeFrom
280+
277281 const partInstance = currentPartInstance ?? nextPartInstance
278282 if ( partInstance ) {
279283 // This is to register a reactive dependency on Rundown-spanning PieceInstances, that we may miss otherwise.
@@ -325,6 +329,7 @@ const getDirectorScreenReactive = (props: DirectorScreenProps): DirectorScreenTr
325329 }
326330 }
327331 }
332+
328333 return {
329334 studio,
330335 segments,
@@ -341,6 +346,7 @@ const getDirectorScreenReactive = (props: DirectorScreenProps): DirectorScreenTr
341346 nextSegment,
342347 nextPartInstance : nextPartInstanceUi ,
343348 nextShowStyleBaseId,
349+ partInstanceToCountTimeFrom : partInstanceToCountTimeFromUi ,
344350 }
345351}
346352
@@ -372,7 +378,11 @@ function useDirectorScreenSubscriptions(props: DirectorScreenProps): void {
372378 useSubscription ( CorelibPubSub . showStyleVariants , null , showStyleVariantIds )
373379 useSubscription ( MeteorPubSub . rundownLayouts , showStyleBaseIds )
374380
375- const { currentPartInstance, nextPartInstance } = useTracker (
381+ const {
382+ currentPartInstance,
383+ nextPartInstance,
384+ partInstanceToCountTimeFrom : firstTakenPartInstance ,
385+ } = useTracker (
376386 ( ) => {
377387 const playlist = RundownPlaylists . findOne ( props . playlistId , {
378388 fields : {
@@ -386,16 +396,27 @@ function useDirectorScreenSubscriptions(props: DirectorScreenProps): void {
386396 if ( playlist ) {
387397 return RundownPlaylistClientUtil . getSelectedPartInstances ( playlist )
388398 } else {
389- return { currentPartInstance : undefined , nextPartInstance : undefined , previousPartInstance : undefined }
399+ return {
400+ currentPartInstance : undefined ,
401+ nextPartInstance : undefined ,
402+ previousPartInstance : undefined ,
403+ partInstanceToCountTimeFrom : undefined ,
404+ }
390405 }
391406 } ,
392407 [ props . playlistId ] ,
393- { currentPartInstance : undefined , nextPartInstance : undefined , previousPartInstance : undefined }
408+ {
409+ currentPartInstance : undefined ,
410+ nextPartInstance : undefined ,
411+ previousPartInstance : undefined ,
412+ partInstanceToCountTimeFrom : undefined ,
413+ }
394414 )
395415
396416 useSubscriptions ( CorelibPubSub . pieceInstances , [
397417 currentPartInstance && [ [ currentPartInstance . rundownId ] , [ currentPartInstance . _id ] , { } ] ,
398418 nextPartInstance && [ [ nextPartInstance . rundownId ] , [ nextPartInstance . _id ] , { } ] ,
419+ firstTakenPartInstance && [ [ firstTakenPartInstance . rundownId ] , [ firstTakenPartInstance . _id ] , { } ] ,
399420 ] )
400421}
401422
@@ -417,11 +438,12 @@ function DirectorScreenRender({
417438 nextPartInstance,
418439 nextSegment,
419440 rundownIds,
441+ partInstanceToCountTimeFrom,
420442} : Readonly < DirectorScreenProps & DirectorScreenTrackedProps > ) {
421443 useSetDocumentClass ( 'dark' , 'xdark' )
422444 const { t } = useTranslation ( )
423445
424- const timingDurations = useTiming ( )
446+ useTiming ( )
425447
426448 // Compute current and next clip player ids (for pieces with AB sessions)
427449 const currentClipPlayer : string | undefined = useTracker ( ( ) => {
@@ -487,11 +509,6 @@ function DirectorScreenRender({
487509
488510 if ( playlist && playlistId && segments ) {
489511 const expectedStart = PlaylistTiming . getExpectedStart ( playlist . timing ) || 0
490- const expectedEnd = PlaylistTiming . getExpectedEnd ( playlist . timing )
491- const expectedDuration = PlaylistTiming . getExpectedDuration ( playlist . timing ) || 0
492- const now = timingDurations . currentTime ?? getCurrentTime ( )
493-
494- const overUnderClock = getPlaylistTimingDiff ( playlist , timingDurations ) ?? 0
495512
496513 // Show countdown if it is the first segment and the current part is untimed:
497514 const currentSegmentIsFirst = currentSegment ?. _rank === 0
@@ -548,37 +565,7 @@ function DirectorScreenRender({
548565
549566 return (
550567 < div className = "director-screen" >
551- < div className = "director-screen__top" >
552- { expectedEnd ? (
553- < div className = "director-screen__top__planned-end" >
554- < div >
555- < PlannedEndComponent value = { expectedEnd } />
556- </ div >
557- { t ( 'Planned End' ) }
558- </ div >
559- ) : null }
560- { expectedEnd ? (
561- < div className = "director-screen__top__time-to" >
562- < div >
563- < TimeToPlannedEndComponent value = { now - expectedEnd } />
564- </ div >
565- < span className = "director-screen__top__planned-to" > { t ( 'Time to planned end' ) } </ span >
566- </ div >
567- ) : (
568- < div >
569- < div >
570- < TimeSincePlannedEndComponent value = { getCurrentTime ( ) - ( expectedStart + expectedDuration ) } />
571- < span className = "director-screen__top__planned-since" > { t ( 'Time since planned end' ) } </ span >
572- </ div >
573- </ div >
574- ) }
575- < div >
576- < div >
577- < OverUnderClockComponent value = { overUnderClock } />
578- </ div >
579- < span className = "director-screen__top__over-under" > { t ( 'Over/Under' ) } </ span >
580- </ div >
581- </ div >
568+ < DirectorScreenTop partInstanceToCountTimeFrom = { partInstanceToCountTimeFrom } playlist = { playlist } />
582569 < div className = "director-screen__body" >
583570 {
584571 // Current Part:
0 commit comments