From e0129bff4e985562156d7cb33afeaaf3cc85f20b Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Thu, 25 Nov 2021 16:48:29 +0200 Subject: [PATCH] 1.5.9 - fixed analytics window showing on clean launcher run And since anime company changed a it their api: - fixed social buttons showing - fixed background picture loading --- README.md | 2 +- package.json | 2 +- src/ts/index.ts | 2 +- src/ts/lib/LauncherLib.ts | 25 ++++++++++--------------- src/ts/lib/LauncherUI.ts | 2 +- src/ts/lib/constants.ts | 2 +- 6 files changed, 15 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 46a0322..48d50f5 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ | Game version | Launcher version | Patch version | | :---: | :---: | :---: | -| 2.3.0 | 1.5.8 | 2.3.0 testing ⚠️ | +| 2.3.0 | 1.5.9 | 2.3.0 testing ⚠️ | We have our own [An Anime Game](https://discord.gg/ck37X6UWBp) discord server where you can ask any questions diff --git a/package.json b/package.json index a01599e..f870bfd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "an-anime-game-launcher", - "version": "1.5.8", + "version": "1.5.9", "description": "An Anime Game Linux Launcher", "author": "Nikita Podvirnyy ", "contributors": [ diff --git a/src/ts/index.ts b/src/ts/index.ts index 7b7537c..173aa18 100644 --- a/src/ts/index.ts +++ b/src/ts/index.ts @@ -67,7 +67,7 @@ $(() => { } }); - if (LauncherLib.getConfig('analytics') !== null && LauncherLib.getConfig('analytics') !== LauncherLib.version) + if (LauncherLib.getConfig('analytics') !== null && LauncherLib.version !== null && LauncherLib.getConfig('analytics') !== LauncherLib.version) ipcRenderer.invoke('open-analytics-participation'); $('#settings').on('mouseenter', () => $('#settings').addClass('hovered')); diff --git a/src/ts/lib/LauncherLib.ts b/src/ts/lib/LauncherLib.ts index 97a6425..6e33de5 100644 --- a/src/ts/lib/LauncherLib.ts +++ b/src/ts/lib/LauncherLib.ts @@ -132,35 +132,30 @@ export default class LauncherLib public static async getBackgroundUri (): Promise { - let background = ''; + let background = this.getConfig('background.file') ? + path.join(constants.launcherDir, this.getConfig('background.file')) : null; - if (!this.getConfig('background.time') || Date.now() > this.getConfig('background.time')!) + if (!this.getConfig('background.time') || Date.now() > this.getConfig('background.time')! || background === null || !fs.existsSync(background)) { await fetch(constants.backgroundUri + this.getConfig('lang.launcher')) .then(res => res.json()) .then(async resdone => { - let prevBackground = this.getConfig('background.file'); + const prevBackground = this.getConfig('background.file'); this.updateConfig('background.time', Date.now() + 7 * 24 * 60 * 60 * 1000); // 7 days this.updateConfig('background.file', resdone.data.adv.background.replace(/.*\//, '')); - if (fs.existsSync(path.join(constants.launcherDir, this.getConfig('background.file')))) - background = path.join(constants.launcherDir, this.getConfig('background.file')); - - else - { - await Tools.downloadFile(resdone.data.adv.background, path.join(constants.launcherDir, this.getConfig('background.file')), () => null).then(() => { - !prevBackground ? - console.log('No old background found') : - fs.unlinkSync(path.join(constants.launcherDir, prevBackground)); + background = path.join(constants.launcherDir, this.getConfig('background.file')); - background = path.join(constants.launcherDir, this.getConfig('background.file')); + if (!fs.existsSync(background)) + { + await Tools.downloadFile(resdone.data.adv.background, background).then(() => { + if (prevBackground && prevBackground != this.getConfig('background.file')) + fs.unlinkSync(path.join(constants.launcherDir, prevBackground)); }); }; }); } - - else background = path.join(constants.launcherDir, this.getConfig('background.file')); return background; } diff --git a/src/ts/lib/LauncherUI.ts b/src/ts/lib/LauncherUI.ts index 0d4e353..d13f6ec 100644 --- a/src/ts/lib/LauncherUI.ts +++ b/src/ts/lib/LauncherUI.ts @@ -279,7 +279,7 @@ export default class LauncherUI public static updateSocial (): void { - const socialUri = `https://${constants.placeholders.lowercase.first}.${constants.placeholders.lowercase.company}.com/launcher/10/${LauncherLib.getConfig('lang.launcher')}?api_url=https%3A%2F%2Fapi-os-takumi.${constants.placeholders.lowercase.company}.com%2Fhk4e_global&prev=false`; + const socialUri = `https://${constants.placeholders.lowercase.first}.${constants.placeholders.lowercase.company}.com/launcher/10/${LauncherLib.getConfig('lang.launcher')}?api_url=https%3A%2F%2Fapi-os-takumi.${constants.placeholders.lowercase.company}.com%2Fhk4e_global&key=gcStgarh&prev=false`; fetch(socialUri) .then(res => res.text()) diff --git a/src/ts/lib/constants.ts b/src/ts/lib/constants.ts index fe7c408..9f8ac5f 100644 --- a/src/ts/lib/constants.ts +++ b/src/ts/lib/constants.ts @@ -51,7 +51,7 @@ export default class constants public static readonly dxvksDir: string = path.join(this.launcherDir, 'dxvks'); public static readonly versionsUri: string = `${this.uri.api}/resource?key=gcStgarh&launcher_id=10`; - public static readonly backgroundUri: string = `${this.uri.api}/content?filter_adv=true&launcher_id=10&language=`; + public static readonly backgroundUri: string = `${this.uri.api}/content?filter_adv=true&launcher_id=10&key=gcStgarh&language=`; public static readonly patchUri: string = `${this.uri.patch}/archive/master.zip`;