projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improvements - untested
[vchess.git]
/
client
/
src
/
utils
/
gameStorage.js
diff --git
a/client/src/utils/gameStorage.js
b/client/src/utils/gameStorage.js
index
cc7dca5
..
4eb6bc7
100644
(file)
--- a/
client/src/utils/gameStorage.js
+++ b/
client/src/utils/gameStorage.js
@@
-7,7
+7,6
@@
// cadence: string,
// increment: integer (seconds),
// type: string ("live" or "corr")
// cadence: string,
// increment: integer (seconds),
// type: string ("live" or "corr")
-// imported: boolean (optional, default false)
// // Game (dynamic) state:
// fen: string,
// moves: array of Move objects,
// // Game (dynamic) state:
// fen: string,
// moves: array of Move objects,
@@
-97,7
+96,8
@@
export const GameStorage = {
},
// Retrieve all local games (running, completed, imported...)
},
// Retrieve all local games (running, completed, imported...)
- getAll: function(callback) {
+ // light: do not retrieve moves or players or clocks (TODO: this is the only usage)
+ getAll: function(light, callback) {
dbOperation((err,db) => {
let objectStore = db.transaction("games").objectStore("games");
let games = [];
dbOperation((err,db) => {
let objectStore = db.transaction("games").objectStore("games");
let games = [];
@@
-105,7
+105,15
@@
export const GameStorage = {
let cursor = event.target.result;
// if there is still another cursor to go, keep running this code
if (cursor) {
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;
+ delete g.players;
+ }
+ games.push(g);
cursor.continue();
} else callback(games);
};
cursor.continue();
} else callback(games);
};