Fix progress meter

This commit is contained in:
Regalijan 2024-03-26 23:00:56 -04:00
parent f8e19b84b6
commit cbfa13e426
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -184,8 +184,9 @@ export default function () {
xhr.upload.onprogress = (e) => {
if (!e.lengthComputable) return;
bytesRead += e.loaded;
setFileProgress(Math.floor((bytesRead / totalSize) * 100));
setFileProgress(
Math.floor(((bytesRead + e.loaded) / totalSize) * 100),
);
};
xhr.upload.onabort = () => {
shouldRecall = true;
@ -197,9 +198,11 @@ export default function () {
setUploading(false);
setFileProgress(0);
};
xhr.upload.onloadend = () => {
xhr.upload.onloadend = (ev) => {
if (i === upload_urls.length - 1) setUploading(false);
bytesRead += ev.total;
setFileProgress(bytesRead);
resolve(null);
};