Finished. Now some last styling
[vchess.git] / client / src / utils / gameStorage.js
index dc65379..630d1c7 100644 (file)
@@ -1,6 +1,6 @@
 // Game object: {
 //   // Static informations:
-//   gameId: string
+//   id: string
 //   vname: string,
 //   fenStart: string,
 //   players: array of sid+id+name,
@@ -39,7 +39,7 @@ function dbOperation(callback)
       alert("Error while loading database: " + event.target.errorCode);
     };
     // Create objectStore for vchess->games
-    let objectStore = db.createObjectStore("games", { keyPath: "gameId" });
+    let objectStore = db.createObjectStore("games", { keyPath: "id" });
     objectStore.createIndex("score", "score"); //to search by game result
   }
 }
@@ -67,7 +67,8 @@ export const GameStorage =
   },
 
   // TODO: also option to takeback a move ?
-  update: function(gameId, obj) //move, fen, clocks, score, initime, ...
+  // obj: chat, move, fen, clocks, score[Msg], initime, ...
+  update: function(gameId, obj)
   {
     if (Number.isInteger(gameId) || !isNaN(parseInt(gameId)))
     {
@@ -79,9 +80,12 @@ export const GameStorage =
           gid: gameId,
           newObj:
           {
+            chat: obj.chat,
             move: obj.move, //may be undefined...
             fen: obj.fen,
             score: obj.score,
+            scoreMsg: obj.scoreMsg,
+            drawOffer: obj.drawOffer,
           }
         }
       );