Several changes

- `cache.json` file was renamed to `.cache.json`
- `Patch.fetchTimeout` was increased up to 5 seconds from 3 seconds
- fixed *possible* issue with `Locales.default()` method:
  before, if you've been passing there a language to set as default,
  it wasn't returning properly
- added notification when all the patch repos are not available
This commit is contained in:
Observer KRypt0n_ 2022-01-25 18:29:41 +02:00
parent 673c9b70d9
commit a7afc472c1
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
4 changed files with 42 additions and 21 deletions

View file

@ -104,7 +104,7 @@ class Paths
*/
public static get cache(): Promise<string>
{
return new Promise(async (resolve) => resolve(`${await this.launcherDir}/cache.json`));
return new Promise(async (resolve) => resolve(`${await this.launcherDir}/.cache.json`));
}
public static readonly prefix = Prefix;

View file

@ -126,7 +126,7 @@ class Stream extends AbstractInstaller
export default class Patch
{
public static fetchTimeout: number|null = 3000;
public static fetchTimeout: number|null = 5000;
/**
* Get information about latest available patch

View file

@ -32,9 +32,13 @@ export default class Locales
public static default(lang: AvailableLocales|null = null): Promise<AvailableLocales>
{
if (lang !== null)
{
Configs.set('lang.launcher', lang);
return Configs.get('lang.launcher') as Promise<AvailableLocales>;
return Promise.resolve(lang);
}
else return Configs.get('lang.launcher') as Promise<AvailableLocales>;
}
/**

View file

@ -368,28 +368,45 @@ export default class State
else
{
const patch = await Patch.latest;
// If the latest game version is, for example, 2.3.0
// and the patch is 2.4.0 preparation, it means that
// 2.4.0 will be released soon, but since it's still not released
// we shouldn't show something about it to user and just let him play the game
if (gameLatest.game.latest.version === patch.version && !patch.applied)
try
{
state = patch.state == 'preparation' ?
'patch-unavailable' : (patch.state == 'testing' ?
'test-patch-available' : 'patch-available');
const patch = await Patch.latest;
// If the latest game version is, for example, 2.3.0
// and the patch is 2.4.0 preparation, it means that
// 2.4.0 will be released soon, but since it's still not released
// we shouldn't show something about it to user and just let him play the game
if (gameLatest.game.latest.version === patch.version && !patch.applied)
{
state = patch.state == 'preparation' ?
'patch-unavailable' : (patch.state == 'testing' ?
'test-patch-available' : 'patch-available');
}
// Patch is more important than game pre-downloading
// because otherwise we will not be able to play the game
else if (gameLatest.pre_download_game && !await Game.isUpdatePredownloaded())
state = 'game-pre-installation-available';
else if (gameLatest.pre_download_game && !await Voice.isUpdatePredownloaded(await Voice.selected))
state = 'game-voice-pre-installation-available';
else state = 'game-launch-available';
}
// Patch is more important than game pre-downloading
// because otherwise we will not be able to play the game
else if (gameLatest.pre_download_game && !await Game.isUpdatePredownloaded())
state = 'game-pre-installation-available';
// Patch.latest can throw an error if all of patch's servers
// are not available, and we must notify user about that
catch
{
state = 'game-launch-available';
else if (gameLatest.pre_download_game && !await Voice.isUpdatePredownloaded(await Voice.selected))
state = 'game-voice-pre-installation-available';
else state = 'game-launch-available';
Notifications.show({
title: 'An Anime Game Launcher',
body: 'All the patch repositories are not available. You\'ll be able to run the game, but launcher can\'t be sure is it patched properly',
icon: `${constants.paths.appDir}/public/images/baal64-transparent.png`,
importance: 'critical'
});
}
}
}
}