From f15375c512229f4fa57edb34a124f4059a058a07 Mon Sep 17 00:00:00 2001 From: Tissevert Date: Tue, 4 Feb 2020 17:29:32 +0100 Subject: [PATCH] Reload games too when loading a saved account --- js/GUI/Screen/Login.js | 2 ++ js/Games.js | 11 ++++++++--- js/Table.js | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/js/GUI/Screen/Login.js b/js/GUI/Screen/Login.js index e394759..883ed96 100644 --- a/js/GUI/Screen/Login.js +++ b/js/GUI/Screen/Login.js @@ -1,6 +1,7 @@ import I18n; import GUI.ConnectedForm; import {dialog, register, select} from GUI.Screen; +import Games; import Messaging; import Session; import Save; @@ -77,6 +78,7 @@ function loadAccount() { fileReader.addEventListener('load', function() { Save.set(null, JSON.parse(fileReader.result)); var name = restoreName(); + Games.reload(); Messaging.reset(); if(name != undefined) { Session.start(name); diff --git a/js/Games.js b/js/Games.js index 91e1cdf..3c07c90 100644 --- a/js/Games.js +++ b/js/Games.js @@ -7,14 +7,14 @@ import Table; import Time; var states = Table.make(function(o) {return 0;}); -states.load('games.state'); var metadata = Table.make(function(o) {return o.value.date;}); -metadata.load('games.metadata'); +reload(); initMessageHandlers(); return { metadata: metadata, - proposal: proposal + proposal: proposal, + reload: reload }; function initMessageHandlers() { @@ -102,3 +102,8 @@ function pushState(gameID, newState) { state.latest = newState; states.save('games.state'); } + +function reload() { + states.load('games.state'); + metadata.load('games.metadata'); +} diff --git a/js/Table.js b/js/Table.js index 66e82bc..2dffe4a 100644 --- a/js/Table.js +++ b/js/Table.js @@ -36,7 +36,7 @@ function Table(sortCriterion) { } function load(path) { - insertAll(Save.get(path) || {}); + items = Save.get(path) || {}; } function remove(key) {