|
|
|
@ -10,12 +10,17 @@ export function loadState() {
|
|
|
|
const serializedState = localStorage.getItem(KEY);
|
|
|
|
const serializedState = localStorage.getItem(KEY);
|
|
|
|
if (!serializedState) return undefined;
|
|
|
|
if (!serializedState) return undefined;
|
|
|
|
let x = JSON.parse(serializedState);
|
|
|
|
let x = JSON.parse(serializedState);
|
|
|
|
// Complatibilty because `state.level` has been renamed to `x.games`.
|
|
|
|
// Compatibility: `state.level` has been renamed to `x.games`.
|
|
|
|
// TODO: Does this work?
|
|
|
|
|
|
|
|
if (x.level) {
|
|
|
|
if (x.level) {
|
|
|
|
x.games = x.level
|
|
|
|
x.games = x.level
|
|
|
|
x.level = undefined
|
|
|
|
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
|
|
|
|
return x
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
return undefined;
|
|
|
|
return undefined;
|
|
|
|
|