- 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
This commit is contained in:
Observer KRypt0n_ 2021-11-25 16:48:29 +02:00
parent 56c782b421
commit e0129bff4e
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
6 changed files with 15 additions and 20 deletions

View file

@ -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

View file

@ -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 <suimin.tu.mu.ga.mi@gmail.com>",
"contributors": [

View file

@ -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'));

View file

@ -132,35 +132,30 @@ export default class LauncherLib
public static async getBackgroundUri (): Promise<string>
{
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;
}

View file

@ -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())

View file

@ -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`;