From cbfa13e426ff0fb7be824aa330810bf8e9815023 Mon Sep 17 00:00:00 2001 From: Regalijan Date: Tue, 26 Mar 2024 23:00:56 -0400 Subject: [PATCH] Fix progress meter --- app/routes/report.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/routes/report.tsx b/app/routes/report.tsx index 2e6c1ef..52198ed 100644 --- a/app/routes/report.tsx +++ b/app/routes/report.tsx @@ -184,8 +184,9 @@ export default function () { xhr.upload.onprogress = (e) => { if (!e.lengthComputable) return; - bytesRead += e.loaded; - setFileProgress(Math.floor((bytesRead / totalSize) * 100)); + setFileProgress( + Math.floor(((bytesRead + e.loaded) / totalSize) * 100), + ); }; xhr.upload.onabort = () => { shouldRecall = true; @@ -197,9 +198,11 @@ export default function () { setUploading(false); setFileProgress(0); }; - xhr.upload.onloadend = () => { + xhr.upload.onloadend = (ev) => { if (i === upload_urls.length - 1) setUploading(false); + bytesRead += ev.total; + setFileProgress(bytesRead); resolve(null); };