fix: progress bar handles added time (#416)

This commit is contained in:
Carlos Valente
2023-05-28 10:26:07 +02:00
committed by GitHub
parent 430c636faa
commit 8abf6aee70
2 changed files with 7 additions and 3 deletions
@@ -72,6 +72,8 @@ export default function Backstage(props: BackstageProps) {
} }
} }
const totalTime = (time.duration ?? 0) + (time.addedTime ?? 0);
return ( return (
<div className={`backstage ${isMirrored ? 'mirror' : ''}`} data-testid='backstage-view'> <div className={`backstage ${isMirrored ? 'mirror' : ''}`} data-testid='backstage-view'>
<NavigationMenu /> <NavigationMenu />
@@ -87,7 +89,7 @@ export default function Backstage(props: BackstageProps) {
<ProgressBar <ProgressBar
className='progress-container' className='progress-container'
now={time.current ?? undefined} now={time.current ?? undefined}
complete={time.duration ?? undefined} complete={totalTime}
hidden={!showProgress} hidden={!showProgress}
/> />
@@ -62,10 +62,12 @@ export default function Timer(props: TimerProps) {
const clock = formatTime(time.clock, formatOptions); const clock = formatTime(time.clock, formatOptions);
const showOverlay = pres.text !== '' && pres.visible; const showOverlay = pres.text !== '' && pres.visible;
const isPlaying = time.playback !== Playback.Pause; const isPlaying = time.playback !== Playback.Pause;
const isNegative = const isNegative =
(time.current ?? 0) < 0 && time.timerType !== TimerType.Clock && time.timerType !== TimerType.CountUp; (time.current ?? 0) < 0 && time.timerType !== TimerType.Clock && time.timerType !== TimerType.CountUp;
const finished = time.playback === Playback.Play && (time.current ?? 0) < 0 && time.startedAt; const finished = time.playback === Playback.Play && (time.current ?? 0) < 0 && time.startedAt;
const totalTime = (time.duration ?? 0) + (time.addedTime ?? 0);
const showEndMessage = (time.current ?? 1) < 0 && viewSettings.endMessage; const showEndMessage = (time.current ?? 1) < 0 && viewSettings.endMessage;
const showProgress = time.playback !== Playback.Stop; const showProgress = time.playback !== Playback.Stop;
const showFinished = finished && (time.timerType !== TimerType.Clock || showEndMessage); const showFinished = finished && (time.timerType !== TimerType.Clock || showEndMessage);
@@ -121,7 +123,7 @@ export default function Timer(props: TimerProps) {
<MultiPartProgressBar <MultiPartProgressBar
className={isPlaying ? 'progress-container' : 'progress-container progress-container--paused'} className={isPlaying ? 'progress-container' : 'progress-container progress-container--paused'}
now={time.current || 0} now={time.current || 0}
complete={time.duration || 0} complete={totalTime}
normalColor={viewSettings.normalColor} normalColor={viewSettings.normalColor}
warning={viewSettings.warningThreshold} warning={viewSettings.warningThreshold}
warningColor={viewSettings.warningColor} warningColor={viewSettings.warningColor}