Add local data clears where applicable

This commit is contained in:
Flashfyre 2024-05-15 00:11:41 -04:00
parent 9a965055b1
commit 7c45da4a01
2 changed files with 11 additions and 8 deletions

View File

@ -414,6 +414,8 @@ export class ReloadSessionPhase extends Phase {
delayElapsed = true;
});
this.scene.gameData.clearLocalData();
(this.systemDataStr ? this.scene.gameData.initSystem(this.systemDataStr) : this.scene.gameData.loadSystem()).then(() => {
if (delayElapsed)
this.end();

View File

@ -359,11 +359,8 @@ export class GameData {
if (cachedSystemData.timestamp > systemData.timestamp) {
console.debug('Use cached system');
systemData = cachedSystemData;
} else {
localStorage.removeItem(`data_${loggedInUser.username}`);
for (let s = 0; s < 5; s++)
localStorage.removeItem(`sessionData${s ? s : ''}_${loggedInUser.username}`);
}
} else
this.clearLocalData();
}
console.debug(systemData);
@ -512,15 +509,19 @@ export class GameData {
if (!response.valid) {
this.scene.clearPhaseQueue();
this.scene.unshiftPhase(new ReloadSessionPhase(this.scene, JSON.stringify(response.systemData)));
localStorage.removeItem(`data_${loggedInUser.username}`);
for (let s = 0; s < 5; s++)
localStorage.removeItem(`sessionData${s ? s : ''}_${loggedInUser.username}`);
this.clearLocalData();
return false;
}
return true;
}
public clearLocalData(): void {
localStorage.removeItem(`data_${loggedInUser.username}`);
for (let s = 0; s < 5; s++)
localStorage.removeItem(`sessionData${s ? s : ''}_${loggedInUser.username}`);
}
public saveSetting(setting: Setting, valueIndex: integer): boolean {
let settings: object = {};
if (localStorage.hasOwnProperty('settings'))