Reduce intesity of Timer.tsx ticks
This commit is contained in:
parent
7d8867e991
commit
e8f2f11734
2 changed files with 8 additions and 5 deletions
|
@ -39,7 +39,7 @@ export function Timer({ locale, surah, ayah, isPaused, audioStatus, onComplete }
|
|||
} else if (ms <= 0) {
|
||||
onComplete(surah, ayah);
|
||||
} else {
|
||||
const tid = setTimeout(() => setMs(ms - 100), 100);
|
||||
const tid = setTimeout(() => setMs(ms - 1000), 1000);
|
||||
return () => clearTimeout(tid);
|
||||
}
|
||||
}, [isStalled, isPaused, ms]);
|
||||
|
@ -50,7 +50,9 @@ export function Timer({ locale, surah, ayah, isPaused, audioStatus, onComplete }
|
|||
|
||||
return (
|
||||
<div className="timer text-base w-10 flex justify-end">
|
||||
{!ms || ms / 1000 <= 0 ? formatNumber(locale, 0) : formatNumber(locale, ms / 1000)}
|
||||
{!ms || ms / 1000 <= 0
|
||||
? formatNumber(locale, 0)
|
||||
: formatNumber(locale, ms / 1000, { maximumFractionDigits: 0 })}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,9 @@ export function T(phrases: PhraseMap<string>): TFunction {
|
|||
};
|
||||
}
|
||||
|
||||
export function formatNumber(locale: TLocale, num: number): string {
|
||||
export function formatNumber(locale: TLocale, num: number, options = {}): string {
|
||||
const numl = locale.name === "ar" ? "ar-SA" : locale.name;
|
||||
const options = { maximumFractionDigits: 1 };
|
||||
return new Intl.NumberFormat(numl, options).format(num);
|
||||
return new Intl.NumberFormat(numl, { maximumFractionDigits: 1, ...options }).format(
|
||||
num,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue