mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 08:54:13 +00:00
fix: take remvze comments into account
This commit is contained in:
parent
71b62ed3dd
commit
0517c31fc1
2 changed files with 6 additions and 7 deletions
|
|
@ -75,7 +75,6 @@ export function Menu() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Divider />
|
|
||||||
<div className={styles.wrapper}>
|
<div className={styles.wrapper}>
|
||||||
<DropdownMenu.Root open={isOpen} onOpenChange={o => setIsOpen(o)}>
|
<DropdownMenu.Root open={isOpen} onOpenChange={o => setIsOpen(o)}>
|
||||||
<DropdownMenu.Trigger asChild>
|
<DropdownMenu.Trigger asChild>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useEffect, useState, useCallback } from 'react';
|
import { useEffect, useState, useCallback, useRef } from 'react';
|
||||||
import { Modal } from '@/components/modal';
|
import { Modal } from '@/components/modal';
|
||||||
import { FaPlay, FaUndo } from 'react-icons/fa/index';
|
import { FaPlay, FaUndo } from 'react-icons/fa/index';
|
||||||
import { useSoundStore } from '@/store';
|
import { useSoundStore } from '@/store';
|
||||||
|
|
@ -18,7 +18,8 @@ export function SleepTimerModal({ onClose, show }: SleepTimerModalProps) {
|
||||||
const [minutes, setMinutes] = useState<string>('0');
|
const [minutes, setMinutes] = useState<string>('0');
|
||||||
const [running, setRunning] = useState(false);
|
const [running, setRunning] = useState(false);
|
||||||
const [timeLeft, setTimeLeft] = useState(0);
|
const [timeLeft, setTimeLeft] = useState(0);
|
||||||
const [timerId, setTimerId] = useState<NodeJS.Timeout | undefined>(undefined);
|
|
||||||
|
const timerId = useRef<NodeJS.Timeout>();
|
||||||
|
|
||||||
const pause = useSoundStore(state => state.pause);
|
const pause = useSoundStore(state => state.pause);
|
||||||
|
|
||||||
|
|
@ -33,9 +34,8 @@ export function SleepTimerModal({ onClose, show }: SleepTimerModalProps) {
|
||||||
setTimeLeft(calculateTotalSeconds());
|
setTimeLeft(calculateTotalSeconds());
|
||||||
}, [calculateTotalSeconds]);
|
}, [calculateTotalSeconds]);
|
||||||
|
|
||||||
// Handle multiple clicks on this. Only the latest click should be taken into account
|
|
||||||
const handleStart = () => {
|
const handleStart = () => {
|
||||||
if (timerId) clearInterval(timerId);
|
if (timerId.current) clearInterval(timerId.current);
|
||||||
|
|
||||||
setTimeLeft(calculateTotalSeconds);
|
setTimeLeft(calculateTotalSeconds);
|
||||||
setRunning(true);
|
setRunning(true);
|
||||||
|
|
@ -54,12 +54,12 @@ export function SleepTimerModal({ onClose, show }: SleepTimerModalProps) {
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
setTimerId(newTimerId);
|
timerId.current = newTimerId;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleReset = () => {
|
const handleReset = () => {
|
||||||
if (timerId) clearInterval(timerId);
|
if (timerId.current) clearInterval(timerId.current);
|
||||||
setTimeLeft(0);
|
setTimeLeft(0);
|
||||||
setRunning(false);
|
setRunning(false);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue