Reload games too when loading a saved account

This commit is contained in:
Tissevert 2020-02-04 17:29:32 +01:00
parent 18a5fc3321
commit f15375c512
3 changed files with 11 additions and 4 deletions

View file

@ -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);

View file

@ -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');
}

View file

@ -36,7 +36,7 @@ function Table(sortCriterion) {
}
function load(path) {
insertAll(Save.get(path) || {});
items = Save.get(path) || {};
}
function remove(key) {