Move progress event handler to inline
This commit is contained in:
parent
c06375ea5c
commit
65d03b680f
@ -168,11 +168,6 @@ export default function () {
|
||||
|
||||
setUploading(true);
|
||||
|
||||
const increaseProgress = (e: ProgressEvent) => {
|
||||
bytesRead += e.loaded;
|
||||
setFileProgress(Math.floor((bytesRead / totalSize) * 100));
|
||||
};
|
||||
|
||||
for (let i = 0; i < upload_urls.length; i++) {
|
||||
await new Promise((resolve) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
@ -186,7 +181,12 @@ export default function () {
|
||||
fileTypes[files[i].name.split(".").at(-1) as string],
|
||||
);
|
||||
|
||||
xhr.upload.addEventListener("progress", increaseProgress);
|
||||
xhr.upload.onprogress = (e) => {
|
||||
if (!e.lengthComputable) return;
|
||||
|
||||
bytesRead += e.loaded;
|
||||
setFileProgress(Math.floor((bytesRead / totalSize) * 100));
|
||||
};
|
||||
xhr.upload.onabort = () => {
|
||||
shouldRecall = true;
|
||||
setUploading(false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user