Move setUploading call into xhr events
This commit is contained in:
parent
0edbe2acec
commit
c9c4cd5af4
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user