Make XHR requests async
This commit is contained in:
parent
d5fa2593c0
commit
2f335cf57a
@ -33,6 +33,10 @@ export function meta() {
|
||||
{
|
||||
title: "Report an Exploiter - Car Crushers",
|
||||
},
|
||||
{
|
||||
name: "description",
|
||||
content: "Use this page to report a cheater",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@ -170,9 +174,10 @@ export default function () {
|
||||
};
|
||||
|
||||
for (let i = 0; i < upload_urls.length; i++) {
|
||||
await new Promise((resolve) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open("PUT", upload_urls[i], false);
|
||||
xhr.open("PUT", upload_urls[i], true);
|
||||
xhr.setRequestHeader(
|
||||
"content-type",
|
||||
(files[i].name.split(".").at(-1) as string).toLowerCase() === "mov"
|
||||
@ -194,9 +199,12 @@ export default function () {
|
||||
};
|
||||
xhr.upload.onloadend = () => {
|
||||
if (i === upload_urls.length - 1) setUploading(false);
|
||||
|
||||
resolve(null);
|
||||
};
|
||||
|
||||
xhr.send(files[i]);
|
||||
});
|
||||
}
|
||||
|
||||
if (shouldRecall) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user