Skip to content

Commit

Permalink
fix: clearInterval from useEffect task tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
GloireMutaliko21 committed Jul 4, 2024
1 parent 3d34eb0 commit bdbfe0a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions apps/web/app/hooks/features/useTimer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,15 @@ export function useTimer() {
}, [timerStatus, setTimerStatus, stopTimerQueryCall, taskId, updateLocalTimerStatus]);

useEffect(() => {
let syncTimerInterval: NodeJS.Timeout;
if (timerStatus?.running) {
const syncTimerInterval = setInterval(() => {
syncTimerInterval = setInterval(() => {
syncTimer();
}, 60000);
return () => clearInterval(syncTimerInterval);
}
return () => {
if (syncTimerInterval) clearInterval(syncTimerInterval);
};
}, [syncTimer, timerStatus]);

// If active team changes then stop the timer
Expand Down

0 comments on commit bdbfe0a

Please sign in to comment.