Improve iOS support
This commit is contained in:
parent
fdfb75a648
commit
e3ef370027
1 changed files with 2 additions and 5 deletions
|
@ -26,21 +26,18 @@ export function Timer({
|
||||||
const [tid, setTid] = useState<ReturnType<typeof setTimeout>>();
|
const [tid, setTid] = useState<ReturnType<typeof setTimeout>>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (tid) {
|
|
||||||
clearTimeout(tid);
|
|
||||||
setTid(undefined);
|
|
||||||
}
|
|
||||||
setMs(ayah.readTimeMs);
|
setMs(ayah.readTimeMs);
|
||||||
}, [ayah.id, soundOn]);
|
}, [ayah.id, soundOn]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if ((soundOn && isStalled) || isPaused) {
|
if ((soundOn && isStalled) || isPaused) {
|
||||||
return;
|
/* no-op */
|
||||||
} else if (ms <= 0) {
|
} else if (ms <= 0) {
|
||||||
setStream([...stream, surah.ayat[ayah.id]]);
|
setStream([...stream, surah.ayat[ayah.id]]);
|
||||||
} else {
|
} else {
|
||||||
setTid(setTimeout(() => setMs(ms - 100), 100));
|
setTid(setTimeout(() => setMs(ms - 100), 100));
|
||||||
}
|
}
|
||||||
|
return () => clearTimeout(tid);
|
||||||
}, [isStalled, isPaused, soundOn, ms]);
|
}, [isStalled, isPaused, soundOn, ms]);
|
||||||
|
|
||||||
return <div className="timer">{formatNumber(ms / 1000, locale)}</div>;
|
return <div className="timer">{formatNumber(ms / 1000, locale)}</div>;
|
||||||
|
|
Loading…
Reference in a new issue