Reload games too when loading a saved account
This commit is contained in:
parent
18a5fc3321
commit
f15375c512
3 changed files with 11 additions and 4 deletions
|
@ -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);
|
||||
|
|
11
js/Games.js
11
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');
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ function Table(sortCriterion) {
|
|||
}
|
||||
|
||||
function load(path) {
|
||||
insertAll(Save.get(path) || {});
|
||||
items = Save.get(path) || {};
|
||||
}
|
||||
|
||||
function remove(key) {
|
||||
|
|
Loading…
Reference in a new issue