mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Fixed promise await structure
This commit is contained in:
parent
a4632f67d0
commit
fe1e526b8d
@ -91,27 +91,30 @@ export class ModManager {
|
|||||||
*/
|
*/
|
||||||
addMod(url, fromFile = false) {
|
addMod(url, fromFile = false) {
|
||||||
if (fromFile && G_IS_STANDALONE) {
|
if (fromFile && G_IS_STANDALONE) {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const modCodeResult = await getIPCRenderer().invoke("fs-job", {
|
getIPCRenderer()
|
||||||
folder: "mods",
|
.invoke("fs-job", {
|
||||||
type: "read",
|
folder: "mods",
|
||||||
filename: url,
|
type: "read",
|
||||||
});
|
filename: url,
|
||||||
if (!modCodeResult.success) return reject("Mod is invalid");
|
})
|
||||||
|
.then(modCodeResult => {
|
||||||
|
if (!modCodeResult.success) return reject("Mod is invalid");
|
||||||
|
|
||||||
const modCode = modCodeResult.data;
|
const modCode = modCodeResult.data;
|
||||||
const modScript = document.createElement("script");
|
const modScript = document.createElement("script");
|
||||||
modScript.textContent = modCode;
|
modScript.textContent = modCode;
|
||||||
modScript.type = "text/javascript";
|
modScript.type = "text/javascript";
|
||||||
try {
|
try {
|
||||||
document.head.appendChild(modScript);
|
document.head.appendChild(modScript);
|
||||||
resolve();
|
resolve();
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.error("Failed to insert mod, bad js:", ex);
|
console.error("Failed to insert mod, bad js:", ex);
|
||||||
this.nextModResolver = null;
|
this.nextModResolver = null;
|
||||||
this.nextModRejector = null;
|
this.nextModRejector = null;
|
||||||
reject("Mod is invalid");
|
reject("Mod is invalid");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else
|
} else
|
||||||
return Promise.race([
|
return Promise.race([
|
||||||
|
Loading…
Reference in New Issue
Block a user