From 5d6a8964584ecf7f5d408abe3989ab217b62d463 Mon Sep 17 00:00:00 2001 From: MonsieurDMA Date: Wed, 1 May 2024 19:49:28 +0200 Subject: [PATCH] Retry saveSystem and saveSession on timeout --- src/system/game-data.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/system/game-data.ts b/src/system/game-data.ts index e11c2dcc572..a5ec3526dbd 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -275,17 +275,22 @@ export class GameData { Utils.apiPost(`savedata/update?datatype=${GameDataType.SYSTEM}`, systemData, undefined, true) .then(response => response.text()) .then(error => { - this.scene.ui.savingIcon.hide(); if (error) { + console.error(error); if (error.startsWith('client version out of date')) { + this.scene.ui.savingIcon.hide(); this.scene.clearPhaseQueue(); this.scene.unshiftPhase(new OutdatedPhase(this.scene)); + return resolve(false); } else if (error.startsWith('session out of date')) { + this.scene.ui.savingIcon.hide(); this.scene.clearPhaseQueue(); this.scene.unshiftPhase(new ReloadSessionPhase(this.scene)); + return resolve(false); } - console.error(error); - return resolve(false); + console.log(`Retrying...`); + this.scene.ui.savingIcon.retry(); + return this.saveSystem().then(resolve); } resolve(true); }); @@ -558,12 +563,14 @@ export class GameData { .then(response => response.text()) .then(error => { if (error) { + console.error(error); if (error.startsWith('session out of date')) { this.scene.clearPhaseQueue(); this.scene.unshiftPhase(new ReloadSessionPhase(this.scene)); + return resolve(false); } - console.error(error); - return resolve(false); + console.log(`Retrying...`); + return this.saveSession(this.scene, skipVerification).then(resolve); } console.debug('Session data saved'); resolve(true);