Skip to content

Commit 20a659d

Browse files
committed
Resumes task after tab switch
1 parent 23fe208 commit 20a659d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

front/taskwizard-front/src/components/StartableTask.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ const StartableTask = ({ task }: { task: TaskInterface }) => {
2020
const cancelRef = useRef(null);
2121
const toast = useToast();
2222
const startedRef = useRef(started);
23-
const setStartedRef = (data: boolean) => {
24-
startedRef.current = data;
25-
setStarted(data);
26-
};
2723
const handleCountChange = (amount: string) => {
2824
const amountNum = parseInt(amount);
2925
setCountAmount(amountNum);
@@ -72,7 +68,9 @@ const StartableTask = ({ task }: { task: TaskInterface }) => {
7268
const handleVisibilityChange = async () => {
7369
if (!document.hidden) {
7470
await stopTask(task.id);
75-
handleStartedStateChange(setStarted, false);
71+
if (startedRef) {
72+
(await startTask(task.id));
73+
}
7674
}
7775
};
7876
document.addEventListener('visibilitychange', handleVisibilityChange);

0 commit comments

Comments
 (0)