Skip to content

Commit

Permalink
fix: change completion condition
Browse files Browse the repository at this point in the history
  • Loading branch information
remvze committed Feb 25, 2024
1 parent a7e5368 commit 1ac5286
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/toolbox/pomodoro/pomodoro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function Pomodoro({ onClose, show }: PomodoroProps) {

const [selectedTab, setSelectedTab] = useState('pomodoro');
const [running, setRunning] = useState(false);
const [timer, setTimer] = useState(10);
const [timer, setTimer] = useState(0);
const interval = useRef<ReturnType<typeof setInterval> | null>(null);

const [times, setTimes] = useState<Record<string, number>>({
Expand Down Expand Up @@ -57,7 +57,7 @@ export function Pomodoro({ onClose, show }: PomodoroProps) {
}, [running]);

useEffect(() => {
if (timer <= 0) {
if (timer <= 0 && running) {
if (interval.current) clearInterval(interval.current);

setRunning(false);
Expand All @@ -66,7 +66,7 @@ export function Pomodoro({ onClose, show }: PomodoroProps) {
[selectedTab]: prev[selectedTab] + 1,
}));
}
}, [timer, selectedTab]);
}, [timer, selectedTab, running]);

useEffect(() => {
const time = times[selectedTab] || 10;
Expand Down

0 comments on commit 1ac5286

Please sign in to comment.