mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 16:02:20 +02:00
Retry saveSystem and saveSession on timeout
This commit is contained in:
parent
81f5c70aaa
commit
5d6a896458
@ -275,18 +275,23 @@ 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));
|
||||
}
|
||||
console.error(error);
|
||||
return resolve(false);
|
||||
}
|
||||
console.log(`Retrying...`);
|
||||
this.scene.ui.savingIcon.retry();
|
||||
return this.saveSystem().then(resolve);
|
||||
}
|
||||
resolve(true);
|
||||
});
|
||||
} else {
|
||||
@ -558,13 +563,15 @@ 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));
|
||||
}
|
||||
console.error(error);
|
||||
return resolve(false);
|
||||
}
|
||||
console.log(`Retrying...`);
|
||||
return this.saveSession(this.scene, skipVerification).then(resolve);
|
||||
}
|
||||
console.debug('Session data saved');
|
||||
resolve(true);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user