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.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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user