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> 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; public static readonly prefix = Prefix;

View file

@ -126,7 +126,7 @@ class Stream extends AbstractInstaller
export default class Patch export default class Patch
{ {
public static fetchTimeout: number|null = 3000; public static fetchTimeout: number|null = 5000;
/** /**
* Get information about latest available patch * 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> public static default(lang: AvailableLocales|null = null): Promise<AvailableLocales>
{ {
if (lang !== null) if (lang !== null)
{
Configs.set('lang.launcher', lang); 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

@ -367,6 +367,8 @@ export default class State
state = 'game-voice-update-required'; state = 'game-voice-update-required';
else else
{
try
{ {
const patch = await Patch.latest; const patch = await Patch.latest;
@ -391,6 +393,21 @@ export default class State
else state = 'game-launch-available'; else state = 'game-launch-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';
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'
});
}
}
} }
} }