mirror of
https://github.com/remvze/moodist.git
synced 2025-09-29 15:30:49 -04:00
fix: change completion condition
This commit is contained in:
parent
a7e5368591
commit
1ac52861d1
@ -20,7 +20,7 @@ export function Pomodoro({ onClose, show }: PomodoroProps) {
|
|||||||
|
|
||||||
const [selectedTab, setSelectedTab] = useState('pomodoro');
|
const [selectedTab, setSelectedTab] = useState('pomodoro');
|
||||||
const [running, setRunning] = useState(false);
|
const [running, setRunning] = useState(false);
|
||||||
const [timer, setTimer] = useState(10);
|
const [timer, setTimer] = useState(0);
|
||||||
const interval = useRef<ReturnType<typeof setInterval> | null>(null);
|
const interval = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||||
|
|
||||||
const [times, setTimes] = useState<Record<string, number>>({
|
const [times, setTimes] = useState<Record<string, number>>({
|
||||||
@ -57,7 +57,7 @@ export function Pomodoro({ onClose, show }: PomodoroProps) {
|
|||||||
}, [running]);
|
}, [running]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (timer <= 0) {
|
if (timer <= 0 && running) {
|
||||||
if (interval.current) clearInterval(interval.current);
|
if (interval.current) clearInterval(interval.current);
|
||||||
|
|
||||||
setRunning(false);
|
setRunning(false);
|
||||||
@ -66,7 +66,7 @@ export function Pomodoro({ onClose, show }: PomodoroProps) {
|
|||||||
[selectedTab]: prev[selectedTab] + 1,
|
[selectedTab]: prev[selectedTab] + 1,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}, [timer, selectedTab]);
|
}, [timer, selectedTab, running]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const time = times[selectedTab] || 10;
|
const time = times[selectedTab] || 10;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user