projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
loseOnRepetition: getter seems enough
[vchess.git]
/
client
/
src
/
utils
/
gameStorage.js
diff --git
a/client/src/utils/gameStorage.js
b/client/src/utils/gameStorage.js
index
fe7335e
..
3e3b684
100644
(file)
--- a/
client/src/utils/gameStorage.js
+++ b/
client/src/utils/gameStorage.js
@@
-51,6
+51,7
@@
function dbOperation(callback) {
}
export const GameStorage = {
}
export const GameStorage = {
+
// Optional callback to get error status
add: function(game, callback) {
dbOperation((err, db) => {
// Optional callback to get error status
add: function(game, callback) {
dbOperation((err, db) => {
@@
-73,14
+74,13
@@
export const GameStorage = {
// obj: chat, move, fen, clocks, score[Msg], initime, ...
update: function(gameId, obj) {
// obj: chat, move, fen, clocks, score[Msg], initime, ...
update: function(gameId, obj) {
- // live
dbOperation((err, db) => {
let objectStore = db
.transaction("games", "readwrite")
.objectStore("games");
objectStore.get(gameId).onsuccess = function(event) {
// Ignoring error silently: shouldn't happen now. TODO?
dbOperation((err, db) => {
let objectStore = db
.transaction("games", "readwrite")
.objectStore("games");
objectStore.get(gameId).onsuccess = function(event) {
// Ignoring error silently: shouldn't happen now. TODO?
- if (event.target.result) {
+ if (
!!
event.target.result) {
let game = event.target.result;
// Hidden tabs are delayed, to prevent multi-updates:
if (obj.moveIdx < game.moves.length) return;
let game = event.target.result;
// Hidden tabs are delayed, to prevent multi-updates:
if (obj.moveIdx < game.moves.length) return;
@@
-89,7
+89,8
@@
export const GameStorage = {
else if (k == "chat") game.chats.push(obj[k]);
else if (k == "chatRead") game.chatRead = Date.now();
else if (k == "delchat") game.chats = [];
else if (k == "chat") game.chats.push(obj[k]);
else if (k == "chatRead") game.chatRead = Date.now();
else if (k == "delchat") game.chats = [];
- else if (k == "playerName") game.players[obj[k].idx] = obj[k].name;
+ else if (k == "playerName")
+ game.players[obj[k].idx].name = obj[k].name;
else game[k] = obj[k];
});
objectStore.put(game); //save updated data
else game[k] = obj[k];
});
objectStore.put(game); //save updated data
@@
-183,4
+184,5
@@
export const GameStorage = {
}
});
}
}
});
}
+
};
};