X-Git-Url: https://git.auder.net/assets/discord.svg?a=blobdiff_plain;f=client%2Fsrc%2Futils%2FgameStorage.js;h=275649662401dd805ab04974fb0632a35a7391f1;hb=b991f731b93e48cebda2e37462aabf61f4a02e1d;hp=ce609af09ad8fdcc1fe93e1fa88d47930490d979;hpb=98b94cc3504937ae0af29a265394dfe52ea1ee67;p=vchess.git diff --git a/client/src/utils/gameStorage.js b/client/src/utils/gameStorage.js index ce609af0..27564966 100644 --- a/client/src/utils/gameStorage.js +++ b/client/src/utils/gameStorage.js @@ -62,6 +62,7 @@ export const GameStorage = { update: function(gameId, obj) { if (Number.isInteger(gameId) || !isNaN(parseInt(gameId))) { // corr: only move, fen and score +console.log(obj.move); ajax("/games", "PUT", { gid: gameId, newObj: { @@ -96,7 +97,8 @@ export const GameStorage = { }, // Retrieve all local games (running, completed, imported...) - getAll: function(callback) { + // light: do not retrieve moves or clocks (TODO: this is the only usage) + getAll: function(light, callback) { dbOperation((err,db) => { let objectStore = db.transaction("games").objectStore("games"); let games = []; @@ -104,7 +106,14 @@ export const GameStorage = { let cursor = event.target.result; // if there is still another cursor to go, keep running this code if (cursor) { - games.push(cursor.value); + let g = cursor.value; + if (light) { + g.movesCount = g.moves.length; + delete g.moves; + delete g.clocks; + delete g.initime; + } + games.push(g); cursor.continue(); } else callback(games); };