fix: resolved linting errors

This commit is contained in:
2025-05-21 15:05:12 +02:00
parent 92d1462010
commit e93b1c1c57
2 changed files with 18 additions and 18 deletions

View File

@@ -108,10 +108,26 @@ export default function PomodoroTimer() {
document.removeEventListener('visibilitychange', handleVisibilityChange);
releaseWakeLock()
}
}, [state])
}, [state, t])
// Timer logic
useEffect(() => {
const handleTimerEnd = async () => {
setState("stopped");
const currentTimerType = currentTimerRef.current.type;
currentTimerRef.current =
currentTimerType === "focus" ? PomoConfigs.break : PomoConfigs.focus;
setTimeLeft(currentTimerRef.current.duration);
const newLabels = currentTimerRef.current.getLabels();
setCurrentLabel(newLabels[Math.floor(Math.random() * newLabels.length)]);
// update habits only after focus sessions
if (selectedHabit && currentTimerType === "focus") {
await completeHabit(selectedHabit);
// The atom will automatically update with the new completions
}
};
let interval: ReturnType<typeof setInterval> | null = null;
if (state === "started") {
@@ -133,22 +149,7 @@ export default function PomodoroTimer() {
return () => {
if (interval) clearInterval(interval);
};
}, [state]);
const handleTimerEnd = async () => {
setState("stopped")
const currentTimerType = currentTimerRef.current.type
currentTimerRef.current = currentTimerType === 'focus' ? PomoConfigs.break : PomoConfigs.focus
setTimeLeft(currentTimerRef.current.duration)
const newLabels = currentTimerRef.current.getLabels();
setCurrentLabel(newLabels[Math.floor(Math.random() * newLabels.length)])
// update habits only after focus sessions
if (selectedHabit && currentTimerType === 'focus') {
await completeHabit(selectedHabit)
// The atom will automatically update with the new completions
}
}
}, [state, timeLeft, PomoConfigs.break, PomoConfigs.focus, completeHabit, selectedHabit]);
const toggleTimer = () => {
setState(prev => prev === 'started' ? 'paused' : 'started')