Record chat history in live games as well
[vchess.git] / client / src / utils / gameStorage.js
index 514448b..6b4c711 100644 (file)
@@ -19,7 +19,7 @@ import { store } from "@/store";
 
 function dbOperation(callback) {
   let db = null;
-  let DBOpenRequest = window.indexedDB.open("vchess", 4);
+  let DBOpenRequest = window.indexedDB.open("vchess", 5);
 
   DBOpenRequest.onerror = function(event) {
     alert(store.state.tr["Database error: stop private browsing, or update your browser"]);
@@ -85,6 +85,8 @@ export const GameStorage = {
           if (obj.moveIdx < game.moves.length) return;
           Object.keys(obj).forEach(k => {
             if (k == "move") game.moves.push(obj[k]);
+            else if (k == "chat") game.chats.push(obj[k]);
+            else if (k == "delchat") game.chats = [];
             else game[k] = obj[k];
           });
           objectStore.put(game); //save updated data