From c9c4cd5af47350900e4e64e522e4f7318f0f0e89 Mon Sep 17 00:00:00 2001 From: Regalijan Date: Mon, 25 Mar 2024 23:54:07 -0400 Subject: [PATCH] Move setUploading call into xhr events --- app/routes/report.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/routes/report.tsx b/app/routes/report.tsx index 4a9fad9..a75fe06 100644 --- a/app/routes/report.tsx +++ b/app/routes/report.tsx @@ -184,16 +184,21 @@ export default function () { xhr.upload.addEventListener("progress", increaseProgress); xhr.upload.onabort = () => { shouldRecall = true; + setUploading(false); + setFileProgress(0); }; xhr.upload.onerror = () => { shouldRecall = true; + setUploading(false); + setFileProgress(0); + }; + xhr.upload.onloadend = () => { + if (i === upload_urls.length - 1) setUploading(false); }; xhr.send(files[i]); } - setUploading(false); - if (shouldRecall) { setLoading(false); await fetch("/api/reports/recall", { @@ -309,7 +314,7 @@ export default function () { Submit {fileProgress}%