Skip to content

Commit

Permalink
Merge pull request #2684 from ever-co/fix/clear-interval-task-time-tr…
Browse files Browse the repository at this point in the history
…acking

ClearInterval From useEffect task tracking
  • Loading branch information
evereq authored Jul 4, 2024
2 parents 3d34eb0 + bdbfe0a commit 1ee0d25
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 1ee0d25

Please sign in to comment.