Draft rematch (not working yet) + fix Crazyhouse getPromotedFen()
[vchess.git] / client / src / utils / gameStorage.js
index 92db299..59efb43 100644 (file)
@@ -43,7 +43,7 @@ export const GameStorage = {
   // Optional callback to get error status
   add: function(game, callback) {
     dbOperation((err,db) => {
-      if (err) {
+      if (!!err) {
         callback("error");
         return;
       }
@@ -51,6 +51,9 @@ export const GameStorage = {
       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);
     });