From 923a6cfb4f0403de50b270148cf0354b0d83d53d Mon Sep 17 00:00:00 2001 From: Alexander Bentkamp Date: Wed, 4 Oct 2023 11:19:01 +0200 Subject: [PATCH] delete outdated local storage --- client/src/state/local_storage.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/src/state/local_storage.ts b/client/src/state/local_storage.ts index 38c0448..6e88db2 100644 --- a/client/src/state/local_storage.ts +++ b/client/src/state/local_storage.ts @@ -10,12 +10,17 @@ export function loadState() { const serializedState = localStorage.getItem(KEY); if (!serializedState) return undefined; let x = JSON.parse(serializedState); - // Complatibilty because `state.level` has been renamed to `x.games`. - // TODO: Does this work? + // Compatibility: `state.level` has been renamed to `x.games`. if (x.level) { x.games = x.level x.level = undefined } + // Compatibility: code has been moved to `data` and inventory has been added. + for (var gameState in x.games) { + if (!x.games[gameState].data) { + x.games[gameState] = null + } + } return x } catch (e) { return undefined;