X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Futils%2FgameStorage.js;h=129866798b63e865e11601bde3364e84abcb05a3;hb=f54f4c26b4c820b14aca298e94644efb20beeed6;hp=59efb43af88338a05e523ef7d6f112d50194a256;hpb=c292ebb2a014646005b01e27253c162f1d639387;p=vchess.git diff --git a/client/src/utils/gameStorage.js b/client/src/utils/gameStorage.js index 59efb43a..12986679 100644 --- a/client/src/utils/gameStorage.js +++ b/client/src/utils/gameStorage.js @@ -83,8 +83,7 @@ export const GameStorage = { }, // Retrieve all local games (running, completed, imported...) - // light: do not retrieve moves or clocks (TODO: this is the only usage) - getAll: function(light, callback) { + getAll: function(callback) { dbOperation((err,db) => { let objectStore = db.transaction("games").objectStore("games"); let games = []; @@ -93,12 +92,11 @@ export const GameStorage = { // if there is still another cursor to go, keep running this code if (cursor) { let g = cursor.value; - if (light) { - g.movesCount = g.moves.length; - delete g.moves; - delete g.clocks; - delete g.initime; - } + // Do not retrieve moves or clocks (unused in list mode) + g.movesCount = g.moves.length; + delete g.moves; + delete g.clocks; + delete g.initime; games.push(g); cursor.continue(); } else callback(games); @@ -113,8 +111,8 @@ export const GameStorage = { dbOperation((err,db) => { let objectStore = db.transaction("games").objectStore("games"); objectStore.get(gameId).onsuccess = function(event) { - if (event.target.result) - callback(event.target.result); + // event.target.result is null if game not found + callback(event.target.result); }; }); },