refactor: supress modifiers in count-up timers

This commit is contained in:
Carlos Valente
2024-06-03 20:42:27 +02:00
committed by Carlos Valente
parent 8b3abe9d61
commit 2076080c5f
2 changed files with 8 additions and 6 deletions
@@ -126,13 +126,14 @@ export default function MinimalTimer(props: MinimalTimerProps) {
const isPlaying = time.playback !== Playback.Pause; const isPlaying = time.playback !== Playback.Pause;
const shouldShowModifiers = time.timerType !== TimerType.Clock && time.timerType !== TimerType.CountUp;
const finished = time.phase === TimerPhase.Negative; const finished = time.phase === TimerPhase.Negative;
const showEndMessage = finished && viewSettings.endMessage && !hideEndMessage; const showEndMessage = finished && viewSettings.endMessage && !hideEndMessage;
const showFinished = finished && !userOptions?.hideOvertime && (time.timerType !== TimerType.Clock || showEndMessage); const showFinished = finished && !userOptions?.hideOvertime && (shouldShowModifiers || showEndMessage);
const showProgress = time.playback !== Playback.Stop; const showProgress = time.playback !== Playback.Stop;
const showWarning = time.phase === TimerPhase.Warning; const showWarning = shouldShowModifiers && time.phase === TimerPhase.Warning;
const showDanger = time.phase === TimerPhase.Danger; const showDanger = shouldShowModifiers && time.phase === TimerPhase.Danger;
let timerColor = viewSettings.normalColor; let timerColor = viewSettings.normalColor;
if (!timerIsTimeOfDay && showProgress && showWarning) timerColor = viewSettings.warningColor; if (!timerIsTimeOfDay && showProgress && showWarning) timerColor = viewSettings.warningColor;
@@ -114,11 +114,12 @@ export default function Timer(props: TimerProps) {
const finished = time.phase === TimerPhase.Negative; const finished = time.phase === TimerPhase.Negative;
const totalTime = (time.duration ?? 0) + (time.addedTime ?? 0); const totalTime = (time.duration ?? 0) + (time.addedTime ?? 0);
const shouldShowModifiers = time.timerType !== TimerType.Clock && time.timerType !== TimerType.CountUp;
const showEndMessage = finished && viewSettings.endMessage; const showEndMessage = finished && 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 && (shouldShowModifiers || showEndMessage);
const showWarning = time.phase === TimerPhase.Warning; const showWarning = shouldShowModifiers && time.phase === TimerPhase.Warning;
const showDanger = time.phase === TimerPhase.Danger; const showDanger = shouldShowModifiers && time.phase === TimerPhase.Danger;
const showBlinking = pres.blink; const showBlinking = pres.blink;
const showBlackout = pres.blackout; const showBlackout = pres.blackout;
const showClock = time.timerType !== TimerType.Clock; const showClock = time.timerType !== TimerType.Clock;