mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-26 16:56:11 +00:00
Fix freezing after a battle ends due to not clearing session
This commit is contained in:
parent
183b53286e
commit
83e9f6d784
@ -85,6 +85,12 @@ export class LoginPhase extends BattlePhase {
|
|||||||
this.end();
|
this.end();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end(): void {
|
||||||
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
|
|
||||||
|
super.end();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove
|
// TODO: Remove
|
||||||
@ -2592,8 +2598,7 @@ export class GameOverPhase extends BattlePhase {
|
|||||||
start() {
|
start() {
|
||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
this.scene.gameData.clearSession();
|
this.scene.gameData.clearSession().then(() => {
|
||||||
|
|
||||||
this.scene.time.delayedCall(1000, () => {
|
this.scene.time.delayedCall(1000, () => {
|
||||||
if (this.victory)
|
if (this.victory)
|
||||||
this.scene.validateAchv(achvs.CLASSIC_VICTORY);
|
this.scene.validateAchv(achvs.CLASSIC_VICTORY);
|
||||||
@ -2608,6 +2613,7 @@ export class GameOverPhase extends BattlePhase {
|
|||||||
this.end();
|
this.end();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUnlocks(party: PlayerPokemon[]): void {
|
handleUnlocks(party: PlayerPokemon[]): void {
|
||||||
|
@ -19,7 +19,7 @@ import { Egg } from "../data/egg";
|
|||||||
import { VoucherType, vouchers } from "./voucher";
|
import { VoucherType, vouchers } from "./voucher";
|
||||||
import { AES, enc } from "crypto-js";
|
import { AES, enc } from "crypto-js";
|
||||||
import { Mode } from "../ui/ui";
|
import { Mode } from "../ui/ui";
|
||||||
import { updateUserInfo } from "../account";
|
import { loggedInUser, updateUserInfo } from "../account";
|
||||||
|
|
||||||
const saveKey = 'x0i2O7WRiANTqPmZ'; // Temporary; secure encryption is not yet necessary
|
const saveKey = 'x0i2O7WRiANTqPmZ'; // Temporary; secure encryption is not yet necessary
|
||||||
|
|
||||||
@ -357,8 +357,6 @@ export class GameData {
|
|||||||
timestamp: new Date().getTime()
|
timestamp: new Date().getTime()
|
||||||
} as SessionSaveData;
|
} as SessionSaveData;
|
||||||
|
|
||||||
console.log(JSON.stringify(sessionData));
|
|
||||||
|
|
||||||
if (!bypassLogin) {
|
if (!bypassLogin) {
|
||||||
Utils.apiPost(`savedata/update?datatype=${GameDataType.SESSION}`, JSON.stringify(sessionData))
|
Utils.apiPost(`savedata/update?datatype=${GameDataType.SESSION}`, JSON.stringify(sessionData))
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
@ -465,8 +463,6 @@ export class GameData {
|
|||||||
return resolve(false);
|
return resolve(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(JSON.parse(response));
|
|
||||||
|
|
||||||
await handleSessionData(response);
|
await handleSessionData(response);
|
||||||
});
|
});
|
||||||
} else
|
} else
|
||||||
@ -474,8 +470,25 @@ export class GameData {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
clearSession(): void {
|
clearSession(): Promise<boolean> {
|
||||||
|
return new Promise<boolean>(resolve => {
|
||||||
|
if (bypassLogin) {
|
||||||
localStorage.removeItem('sessionData');
|
localStorage.removeItem('sessionData');
|
||||||
|
return resolve(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateUserInfo().then(success => {
|
||||||
|
if (success !== null && !success)
|
||||||
|
return resolve(false);
|
||||||
|
Utils.apiFetch(`savedata/delete?datatype=${GameDataType.SESSION}`).then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
loggedInUser.hasGameSession = false;
|
||||||
|
return resolve(true);
|
||||||
|
}
|
||||||
|
resolve(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
parseSessionData(dataStr: string): SessionSaveData {
|
parseSessionData(dataStr: string): SessionSaveData {
|
||||||
|
Loading…
Reference in New Issue
Block a user