From 0ae7b8618f962e6b437ccec617e76d98c6ba1465 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Sun, 24 Nov 2024 16:49:00 +0100 Subject: [PATCH] Reset game state when new/different game has started --- src/alfagok/static/game.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/alfagok/static/game.js b/src/alfagok/static/game.js index 81eb4fb..f5e2699 100644 --- a/src/alfagok/static/game.js +++ b/src/alfagok/static/game.js @@ -35,6 +35,9 @@ document.addEventListener('alpine:init', () => { console.log(result); this.loading = false; if (result.game) { + if (this.gameID !== result.game) { + this.setEmptyGameState(); + } return this.gameID = result.game; } }, @@ -116,10 +119,6 @@ document.addEventListener('alpine:init', () => { this.getGameID(); }, - // # Local Storage Persistence - resetSavedGames() { - localStorage.removeItem(this.savedGameKey); - }, // # Countdown timer getFormattedTime(milliseconds) { if (!Number.isInteger(milliseconds)) {