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.addEventListener("progress", increaseProgress);
xhr.upload.onabort = () => { xhr.upload.onabort = () => {
shouldRecall = true; shouldRecall = true;
setUploading(false);
setFileProgress(0);
}; };
xhr.upload.onerror = () => { xhr.upload.onerror = () => {
shouldRecall = true; shouldRecall = true;
setUploading(false);
setFileProgress(0);
};
xhr.upload.onloadend = () => {
if (i === upload_urls.length - 1) setUploading(false);
}; };
xhr.send(files[i]); xhr.send(files[i]);
} }
setUploading(false);
if (shouldRecall) { if (shouldRecall) {
setLoading(false); setLoading(false);
await fetch("/api/reports/recall", { await fetch("/api/reports/recall", {
@ -309,7 +314,7 @@ export default function () {
Submit Submit
</Button> </Button>
<CircularProgress <CircularProgress
display={uploading ? "" : "none"} display={uploading ? undefined : "none"}
value={fileProgress} value={fileProgress}
> >
<CircularProgressLabel>{fileProgress}%</CircularProgressLabel> <CircularProgressLabel>{fileProgress}%</CircularProgressLabel>