mirror of
https://github.com/arc53/DocsGPT.git
synced 2026-04-28 13:00:30 +00:00
chore: added cleanup fxn for TrainingProgress timeout fxn
This commit is contained in:
@@ -94,8 +94,10 @@ export default function Upload({
|
|||||||
function TrainingProgress() {
|
function TrainingProgress() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(progress?.percentage ?? 0) < 100 &&
|
let timeoutID: number | undefined;
|
||||||
setTimeout(() => {
|
|
||||||
|
if ((progress?.percentage ?? 0) < 100) {
|
||||||
|
timeoutID = setTimeout(() => {
|
||||||
const apiHost = import.meta.env.VITE_API_HOST;
|
const apiHost = import.meta.env.VITE_API_HOST;
|
||||||
fetch(`${apiHost}/api/task_status?task_id=${progress?.taskId}`)
|
fetch(`${apiHost}/api/task_status?task_id=${progress?.taskId}`)
|
||||||
.then((data) => data.json())
|
.then((data) => data.json())
|
||||||
@@ -133,6 +135,14 @@ export default function Upload({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// cleanup
|
||||||
|
return () => {
|
||||||
|
if (timeoutID !== undefined) {
|
||||||
|
clearTimeout(timeoutID);
|
||||||
|
}
|
||||||
|
};
|
||||||
}, [progress, dispatch]);
|
}, [progress, dispatch]);
|
||||||
return (
|
return (
|
||||||
<Progress
|
<Progress
|
||||||
|
|||||||
Reference in New Issue
Block a user