Improved Launcher.state.update() method performance

This commit is contained in:
Observer KRypt0n_ 2022-01-04 17:07:24 +02:00
parent ee66769cb1
commit 66f852ddea
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA

View file

@ -180,7 +180,6 @@ export default class State
let state: LauncherState|null = null;
const runner = await Runners.current();
const dxvk = await DXVK.current();
// Check if the wine is installed
if (runner === null)
@ -216,8 +215,12 @@ export default class State
}
}
else
{
const dxvk = await DXVK.current();
// Check if the DXVK is installed
else if (dxvk === null)
if (dxvk === null)
{
debugThread.log('DXVK is not specified');
@ -253,9 +256,19 @@ export default class State
else
{
const gameCurrent = await Game.current;
const gameLatest = await Game.getLatestData();
const patch = await Patch.latest;
if (gameCurrent === null)
state = 'game-installation-available';
else
{
const gameLatest = await Game.getLatestData();
if (gameCurrent != gameLatest.game.latest.version)
state = 'game-update-available';
else
{
const installedVoices = await Voice.installed;
const selectedVoices = await Voice.selected;
@ -272,17 +285,15 @@ export default class State
}
}
if (gameCurrent === null)
state = 'game-installation-available';
else if (gameCurrent != gameLatest.game.latest.version)
state = 'game-update-available';
// TODO: download default voice language if user removed all of them
else if (voiceUpdateRequired)
if (voiceUpdateRequired)
state = 'game-voice-update-required';
else if (!patch.applied)
else
{
const patch = await Patch.latest;
if (!patch.applied)
{
state = patch.state == 'preparation' ?
'patch-unavailable' : (patch.state == 'testing' ?
@ -296,6 +307,9 @@ export default class State
state = 'game-voice-pre-installation-available';
else state = 'game-launch-available';
}
}
}
debugThread.log(`Updated state: ${state}`);
@ -303,6 +317,7 @@ export default class State
resolve(state);
}
}
});
}
};