Add unambiguous section in the PGN + some fixes + code formatting and fix typos
[vchess.git] / client / src / utils / compgameStorage.js
index a5c58af..e30a69f 100644 (file)
@@ -15,7 +15,8 @@ function dbOperation(callback) {
   let DBOpenRequest = window.indexedDB.open("vchess_comp", 4);
 
   DBOpenRequest.onerror = function(event) {
-    alert(store.state.tr["Database error: stop private browsing, or update your browser"]);
+    alert(store.state.tr[
+      "Database error: stop private browsing, or update your browser"]);
     callback("error", null);
   };
 
@@ -27,7 +28,11 @@ function dbOperation(callback) {
 
   DBOpenRequest.onupgradeneeded = function(event) {
     let db = event.target.result;
-    db.createObjectStore("compgames", { keyPath: "vname" });
+    let upgradeTransaction = event.target.transaction;
+    if (!db.objectStoreNames.contains("compgames"))
+      db.createObjectStore("compgames", { keyPath: "vname" });
+    else
+      upgradeTransaction.objectStore("compgames");
   };
 }