mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-21 06:34:30 +01:00
fix: resolved linting errors
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { ResponsiveContainer } from 'recharts'
|
|
||||||
import ClientWrapper from './ClientWrapper'
|
import ClientWrapper from './ClientWrapper'
|
||||||
import Header from './Header'
|
import Header from './Header'
|
||||||
import Navigation from './Navigation'
|
import Navigation from './Navigation'
|
||||||
|
|||||||
@@ -108,10 +108,26 @@ export default function PomodoroTimer() {
|
|||||||
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
||||||
releaseWakeLock()
|
releaseWakeLock()
|
||||||
}
|
}
|
||||||
}, [state])
|
}, [state, t])
|
||||||
|
|
||||||
// Timer logic
|
// Timer logic
|
||||||
useEffect(() => {
|
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;
|
let interval: ReturnType<typeof setInterval> | null = null;
|
||||||
|
|
||||||
if (state === "started") {
|
if (state === "started") {
|
||||||
@@ -133,22 +149,7 @@ export default function PomodoroTimer() {
|
|||||||
return () => {
|
return () => {
|
||||||
if (interval) clearInterval(interval);
|
if (interval) clearInterval(interval);
|
||||||
};
|
};
|
||||||
}, [state]);
|
}, [state, timeLeft, PomoConfigs.break, PomoConfigs.focus, completeHabit, selectedHabit]);
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const toggleTimer = () => {
|
const toggleTimer = () => {
|
||||||
setState(prev => prev === 'started' ? 'paused' : 'started')
|
setState(prev => prev === 'started' ? 'paused' : 'started')
|
||||||
|
|||||||
Reference in New Issue
Block a user