Move setUploading call into xhr events

This commit is contained in:
Regalijan 2024-03-25 23:54:07 -04:00
parent 0edbe2acec
commit c9c4cd5af4
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -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
</Button>
<CircularProgress
display={uploading ? "" : "none"}
display={uploading ? undefined : "none"}
value={fileProgress}
>
<CircularProgressLabel>{fileProgress}%</CircularProgressLabel>