From 310a96183fe7ec8dba812a9383145f6fbd4a589e Mon Sep 17 00:00:00 2001 From: Maroxy Date: Mon, 18 Oct 2021 10:26:57 +0200 Subject: [PATCH] Fix image not showing on first launch when build --- src/ts/Genshinlib.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ts/Genshinlib.ts b/src/ts/Genshinlib.ts index 96e3804..902f83f 100644 --- a/src/ts/Genshinlib.ts +++ b/src/ts/Genshinlib.ts @@ -102,7 +102,7 @@ export class Genshinlib { await fetch(`https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/content?filter_adv=true&launcher_id=10&language=${this.lang.launcher}`) .then(res => res.json()) - .then(resdone => { + .then(async resdone => { let oldbg = this.getConfig().background.name; this.setConfig({ @@ -119,10 +119,10 @@ export class Genshinlib } else { - this.downloadFile(resdone.data.adv.background, path.join(this.launcherDir, this.getConfig().background.name), (current: number, total: number, difference: number) => null).then(() => { - oldbg ? fs.unlinkSync(path.join(this.launcherDir, oldbg)) : ''; + await this.downloadFile(resdone.data.adv.background, path.join(this.launcherDir, this.getConfig().background.name), (current: number, total: number, difference: number) => null).then(() => { + !oldbg ? console.log('No Old Background Found.') : fs.unlinkSync(path.join(this.launcherDir, oldbg)); bg = path.join(this.launcherDir, this.getConfig().background.name); - }) + }); }; }); }