projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix games ordering in MyGames, fix en-passant mistake in Rifle variant
[vchess.git]
/
client
/
src
/
utils
/
gameStorage.js
diff --git
a/client/src/utils/gameStorage.js
b/client/src/utils/gameStorage.js
index
5c094dc
..
59efb43
100644
(file)
--- a/
client/src/utils/gameStorage.js
+++ b/
client/src/utils/gameStorage.js
@@
-43,7
+43,7
@@
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) => {
- if (err) {
+ if (
!!
err) {
callback("error");
return;
}
callback("error");
return;
}
@@
-51,6
+51,9
@@
export const GameStorage = {
transaction.oncomplete = function() {
callback(); //everything's fine
};
transaction.oncomplete = function() {
callback(); //everything's fine
};
+ transaction.onerror = function(err) {
+ callback(err); //duplicate key error (most likely)
+ };
let objectStore = transaction.objectStore("games");
objectStore.add(game);
});
let objectStore = transaction.objectStore("games");
objectStore.add(game);
});
@@
-122,7
+125,7
@@
export const GameStorage = {
if (!err) {
let transaction = db.transaction(["games"], "readwrite");
transaction.oncomplete = function() {
if (!err) {
let transaction = db.transaction(["games"], "readwrite");
transaction.oncomplete = function() {
- callback(
{}
); //everything's fine
+ callback(); //everything's fine
};
transaction.objectStore("games").delete(gameId);
}
};
transaction.objectStore("games").delete(gameId);
}