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",
|
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++) {
|
for (let i = 0; i < upload_urls.length; i++) {
|
||||||
|
await new Promise((resolve) => {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
xhr.open("PUT", upload_urls[i], false);
|
xhr.open("PUT", upload_urls[i], true);
|
||||||
xhr.setRequestHeader(
|
xhr.setRequestHeader(
|
||||||
"content-type",
|
"content-type",
|
||||||
(files[i].name.split(".").at(-1) as string).toLowerCase() === "mov"
|
(files[i].name.split(".").at(-1) as string).toLowerCase() === "mov"
|
||||||
@ -194,9 +199,12 @@ export default function () {
|
|||||||
};
|
};
|
||||||
xhr.upload.onloadend = () => {
|
xhr.upload.onloadend = () => {
|
||||||
if (i === upload_urls.length - 1) setUploading(false);
|
if (i === upload_urls.length - 1) setUploading(false);
|
||||||
|
|
||||||
|
resolve(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.send(files[i]);
|
xhr.send(files[i]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldRecall) {
|
if (shouldRecall) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user