From e8f2f117343bf43f8e28488479e0afff6372df16 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Fri, 24 May 2024 15:57:42 -0300 Subject: [PATCH] Reduce intesity of Timer.tsx ticks --- src/js/components/SurahStream/Timer.tsx | 6 ++++-- src/js/lib/t.ts | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/js/components/SurahStream/Timer.tsx b/src/js/components/SurahStream/Timer.tsx index 7d6a72f..81b286a 100644 --- a/src/js/components/SurahStream/Timer.tsx +++ b/src/js/components/SurahStream/Timer.tsx @@ -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 (
- {!ms || ms / 1000 <= 0 ? formatNumber(locale, 0) : formatNumber(locale, ms / 1000)} + {!ms || ms / 1000 <= 0 + ? formatNumber(locale, 0) + : formatNumber(locale, ms / 1000, { maximumFractionDigits: 0 })}
); } diff --git a/src/js/lib/t.ts b/src/js/lib/t.ts index e47cf3a..f65af52 100644 --- a/src/js/lib/t.ts +++ b/src/js/lib/t.ts @@ -17,8 +17,9 @@ export function T(phrases: PhraseMap): 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, + ); }