@@ -3,6 +3,7 @@ import { RundownTTimer } from '@sofie-automation/corelib/dist/dataModel/RundownP
33import { useTiming } from '../RundownTiming/withTiming'
44import { RundownUtils } from '../../../lib/rundown'
55import classNames from 'classnames'
6+ import { getCurrentTime } from '../../../lib/systemTime'
67
78interface IProps {
89 tTimers : [ RundownTTimer , RundownTTimer , RundownTTimer ]
@@ -11,13 +12,13 @@ interface IProps {
1112export const RundownHeaderTimers : React . FC < IProps > = ( { tTimers } ) => {
1213 useTiming ( )
1314
14- const hasActiveTimers = tTimers . some ( ( t ) => t . mode )
15+ const activeTimers = tTimers . filter ( ( t ) => t . mode )
1516
16- if ( ! hasActiveTimers ) return null
17+ if ( activeTimers . length == 0 ) return null
1718
1819 return (
1920 < div className = "timing__header_t-timers" >
20- { tTimers . map ( ( timer ) => (
21+ { activeTimers . map ( ( timer ) => (
2122 < SingleTimer key = { timer . index } timer = { timer } />
2223 ) ) }
2324 </ div >
@@ -29,29 +30,29 @@ interface ISingleTimerProps {
2930}
3031
3132function SingleTimer ( { timer } : ISingleTimerProps ) {
32- if ( ! timer . mode ) return null
33+ const now = getCurrentTime ( )
3334
34- const now = Date . now ( )
35-
36- const isRunning = timer . state !== null && ! timer . state . paused
35+ const isRunning = ! ! timer . state && ! timer . state . paused
3736
3837 const diff = calculateDiff ( timer , now )
3938 const timeStr = RundownUtils . formatDiffToTimecode ( Math . abs ( diff ) , false , true , true , false , true )
4039 const parts = timeStr . split ( ':' )
4140
4241 const timerSign = diff >= 0 ? '+' : '-'
4342
43+ const isCountingDown = timer . mode ?. type === 'countdown' && diff < 0 && isRunning
44+
4445 return (
4546 < div
4647 className = { classNames ( 'timing__header_t-timers__timer' , {
4748 'timing__header_t-timers__timer__countdown' : timer . mode ! . type === 'countdown' ,
4849 'timing__header_t-timers__timer__freeRun' : timer . mode ! . type === 'freeRun' ,
4950 'timing__header_t-timers__timer__isRunning' : isRunning ,
5051 'timing__header_t-timers__timer__isPaused' : ! isRunning ,
51- 'timing__header_t-timers__timer__isCountingDown' : timer . mode ! . type === 'countdown' ,
52- 'timing__header_t-timers__timer__isCountingUp' : timer . mode ! . type === 'countdown' ,
52+ 'timing__header_t-timers__timer__isCountingDown' : timer . mode ! . type === 'countdown' && isCountingDown ,
53+ 'timing__header_t-timers__timer__isCountingUp' : timer . mode ! . type === 'countdown' && ! isCountingDown ,
5354 'timing__header_t-timers__timer__isComplete' :
54- timer . mode ! . type === 'countdown' && timer . state !== null && timer . state . paused ,
55+ timer . mode ! . type === 'countdown' && timer . state !== null && diff <= 0 ,
5556 } ) }
5657 >
5758 < span className = "timing__header_t-timers__timer__label" > { timer . label } </ span >
@@ -61,7 +62,7 @@ function SingleTimer({ timer }: ISingleTimerProps) {
6162 < React . Fragment key = { i } >
6263 < span
6364 className = { classNames ( 'timing__header_t-timers__timer__part' , {
64- 'timing__header_t-timers__timer__part--dimmed' : p === '00' ,
65+ 'timing__header_t-timers__timer__part--dimmed' : Math . abs ( diff ) < [ 3600000 , 60000 , 1 ] [ i ] ,
6566 } ) }
6667 >
6768 { p }
0 commit comments