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 I18n;
|
||||||
import GUI.ConnectedForm;
|
import GUI.ConnectedForm;
|
||||||
import {dialog, register, select} from GUI.Screen;
|
import {dialog, register, select} from GUI.Screen;
|
||||||
|
import Games;
|
||||||
import Messaging;
|
import Messaging;
|
||||||
import Session;
|
import Session;
|
||||||
import Save;
|
import Save;
|
||||||
|
@ -77,6 +78,7 @@ function loadAccount() {
|
||||||
fileReader.addEventListener('load', function() {
|
fileReader.addEventListener('load', function() {
|
||||||
Save.set(null, JSON.parse(fileReader.result));
|
Save.set(null, JSON.parse(fileReader.result));
|
||||||
var name = restoreName();
|
var name = restoreName();
|
||||||
|
Games.reload();
|
||||||
Messaging.reset();
|
Messaging.reset();
|
||||||
if(name != undefined) {
|
if(name != undefined) {
|
||||||
Session.start(name);
|
Session.start(name);
|
||||||
|
|
11
js/Games.js
11
js/Games.js
|
@ -7,14 +7,14 @@ import Table;
|
||||||
import Time;
|
import Time;
|
||||||
|
|
||||||
var states = Table.make(function(o) {return 0;});
|
var states = Table.make(function(o) {return 0;});
|
||||||
states.load('games.state');
|
|
||||||
var metadata = Table.make(function(o) {return o.value.date;});
|
var metadata = Table.make(function(o) {return o.value.date;});
|
||||||
metadata.load('games.metadata');
|
reload();
|
||||||
initMessageHandlers();
|
initMessageHandlers();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
metadata: metadata,
|
metadata: metadata,
|
||||||
proposal: proposal
|
proposal: proposal,
|
||||||
|
reload: reload
|
||||||
};
|
};
|
||||||
|
|
||||||
function initMessageHandlers() {
|
function initMessageHandlers() {
|
||||||
|
@ -102,3 +102,8 @@ function pushState(gameID, newState) {
|
||||||
state.latest = newState;
|
state.latest = newState;
|
||||||
states.save('games.state');
|
states.save('games.state');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reload() {
|
||||||
|
states.load('games.state');
|
||||||
|
metadata.load('games.metadata');
|
||||||
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ function Table(sortCriterion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function load(path) {
|
function load(path) {
|
||||||
insertAll(Save.get(path) || {});
|
items = Save.get(path) || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove(key) {
|
function remove(key) {
|
||||||
|
|
Loading…
Reference in a new issue