From e93b1c1c57984f86fd6037b68dd21b51c82946e4 Mon Sep 17 00:00:00 2001 From: ManInDark <61268856+ManInDark@users.noreply.github.com> Date: Wed, 21 May 2025 15:05:12 +0200 Subject: [PATCH] fix: resolved linting errors --- components/Layout.tsx | 1 - components/PomodoroTimer.tsx | 35 ++++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/components/Layout.tsx b/components/Layout.tsx index 9c60494..668ab73 100644 --- a/components/Layout.tsx +++ b/components/Layout.tsx @@ -1,4 +1,3 @@ -import { ResponsiveContainer } from 'recharts' import ClientWrapper from './ClientWrapper' import Header from './Header' import Navigation from './Navigation' diff --git a/components/PomodoroTimer.tsx b/components/PomodoroTimer.tsx index b34bdca..0289bae 100644 --- a/components/PomodoroTimer.tsx +++ b/components/PomodoroTimer.tsx @@ -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 | 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')