mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 16:43:16 +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() {
|
||||
const dispatch = useDispatch();
|
||||
useEffect(() => {
|
||||
(progress?.percentage ?? 0) < 100 &&
|
||||
setTimeout(() => {
|
||||
let timeoutID: number | undefined;
|
||||
|
||||
if ((progress?.percentage ?? 0) < 100) {
|
||||
timeoutID = setTimeout(() => {
|
||||
const apiHost = import.meta.env.VITE_API_HOST;
|
||||
fetch(`${apiHost}/api/task_status?task_id=${progress?.taskId}`)
|
||||
.then((data) => data.json())
|
||||
@@ -133,6 +135,14 @@ export default function Upload({
|
||||
}
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// cleanup
|
||||
return () => {
|
||||
if (timeoutID !== undefined) {
|
||||
clearTimeout(timeoutID);
|
||||
}
|
||||
};
|
||||
}, [progress, dispatch]);
|
||||
return (
|
||||
<Progress
|
||||
|
||||
Reference in New Issue
Block a user