Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move setUploading call into xhr events
  • Loading branch information
regalijan committed Mar 26, 2024
1 parent 0edbe2a commit c9c4cd5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/routes/report.tsx
Expand Up @@ -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", {
Expand Down Expand Up @@ -309,7 +314,7 @@ export default function () {
Submit
</Button>
<CircularProgress
display={uploading ? "" : "none"}
display={uploading ? undefined : "none"}
value={fileProgress}
>
<CircularProgressLabel>{fileProgress}%</CircularProgressLabel>
Expand Down

0 comments on commit c9c4cd5

Please sign in to comment.