refactor: fix missed first update (#1031)

This commit is contained in:
Carlos Valente
2024-06-03 20:27:51 +02:00
committed by GitHub
parent 73e4a15718
commit c2039866b4
5 changed files with 86 additions and 43 deletions
@@ -16,12 +16,9 @@ interface TimerDisplayProps {
export default function TimerDisplay(props: TimerDisplayProps) {
const { time } = props;
if (time == null) {
return <div className={style.timer}>{timerPlaceholder}</div>;
}
const isNegative = time < 0;
const display = millisToString(Math.abs(time), { fallback: timerPlaceholder });
const isNegative = (time ?? 0) < 0;
const display =
time == null ? timerPlaceholder : millisToString(time, { fallback: timerPlaceholder }).replace('-', '');
const classes = cx([style.timer, isNegative ? style.finished : null]);
return <div className={classes}>{display}</div>;