Browse Source

use indexedDB storage for gundb

Nikolay Suslov 6 years ago
parent
commit
df387f4401
2 changed files with 14 additions and 3 deletions
  1. 7 3
      public/app.js
  2. 7 0
      public/index.html

+ 7 - 3
public/app.js

@@ -75,7 +75,10 @@ class App {
 
     const dbConnection = new Promise((resolve, reject) => {
 
-      this.db = Gun(this.dbHost);
+      const opt = { peers: this.dbHost, localStorage: false, store: null }
+      opt.store = RindexedDB(opt);
+      this.db = Gun(opt);
+
       this.user = this.db.user();
       window._LCSDB = this.db;
       window._LCSUSER = this.user;
@@ -123,7 +126,7 @@ class App {
   }
 
   initUser() {
-    _LCSUSER.recall({ sessionStorage: true });
+    this.db.user().recall({ sessionStorage: 1 });
   }
 
 
@@ -1133,7 +1136,8 @@ class App {
             class: "mdc-button mdc-button--raised mdc-card__action",
             $text: "Go to new cloned World!",
             onclick: function (e) {
-              window.location.pathname = '/' + userName + '/' + worldID + '/about'
+              let myName = _LCSUSER.is.alias;
+              window.location.pathname = '/' + myName + '/' + worldID + '/about'
             }
           }
         ]

+ 7 - 0
public/index.html

@@ -27,6 +27,12 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
     <script src="/lib/gundb/lib/not.js"></script>
     <script src="/lib/gundb/lib/open.js"></script>
     <script src="/lib/gundb/lib/load.js"></script>
+
+    <script src="/lib/gundb/lib/radix.js"></script>
+    <script src="/lib/gundb/lib/radisk.js"></script>
+    <script src="/lib/gundb/lib/store.js"></script>
+    <script src="/lib/gundb/lib/rindexed.js"></script>
+
     <!-- <script src="/gun/as.js"></script>
   <script src="/gun/nts.js"></script> -->
 
@@ -72,6 +78,7 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
     <link rel="stylesheet" type="text/css" href="/lib/index.css" />
 
     <script type="module">
+        localStorage.clear();
         import { App } from '/app.js';
         window.onload = new App;
     </script>