瀏覽代碼

more rework

Nikolay Suslov 4 年之前
父節點
當前提交
6563e4b0f5
共有 3 個文件被更改,包括 27 次插入15 次删除
  1. 25 12
      public/app.js
  2. 1 0
      public/vwf.js
  3. 1 3
      public/web/index-app.js

+ 25 - 12
public/app.js

@@ -1542,33 +1542,46 @@ class App {
 
     }).then(val => {
 
-      let res = val['index_vwf_config_yaml'];
-      var conf = "";
+      let fileConf = val['index_vwf_config_yaml'];
+      vwf.conf = {};
 
-      if (res) {
-        let config = YAML.parse(res);
-        conf = config
+      if (fileConf) {
+        let config = YAML.parse(fileConf);
+        vwf.conf = config
       }
 
       let manualSettings = localStorage.getItem('lcs_app_manual_settings');
       if (manualSettings) {
         let manualConf = JSON.parse(manualSettings);
-        conf.model = manualConf.model;
-        conf.view = manualConf.view;
+        wf.conf.model = manualConf.model;
+        wf.conf.view = manualConf.view;
       }
 
       //check & set default proxy for world
-      if(val.proxy){
-        vwf.proxy = val.proxy;
-      }
+      vwf.proxy = val.proxy ? val.proxy: _LCS_WORLD_USER.pub
+
+      // Try to load all required docs from Gun DB...
+      let promises = []
 
+      let worldPromise = new Promise (res => _LCSDB.user(_LCS_WORLD_USER.pub).get('worlds').get(space).load(res));
+      promises.push(worldPromise);
 
-      return conf
+      if(savename){  
+        let entryPath = 'savestate_/' + space+ '/' + savename + '_vwf_json';
+        let savePromise = new Promise (res => _LCSDB.user(_LCS_WORLD_USER.pub).get('documents').get(space).path(entryPath).load(res,{wait:400}));
+        promises.push(savePromise);
+      }
+
+      let proxyPromise = new Promise(res => _LCSDB.user(vwf.proxy).get('proxy').load(res, {wait:400}));
+      promises.push(proxyPromise);
+      
+      return Promise.all(promises)
+     
 
     }).then(res => {
       var userLibraries = { model: {}, view: {} };
       var application;
-      vwf.loadConfiguration(application, userLibraries, res, compatibilityCheck);
+      vwf.loadConfiguration(application, userLibraries, vwf.conf, compatibilityCheck);
 
     })
 

+ 1 - 0
public/vwf.js

@@ -46,6 +46,7 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
         /// @private
 
         this.proxy = undefined;
+        this.conf = undefined;
 
         this.configuration = undefined; // require( "vwf/configuration" ).active; // "active" updates in place and changes don't invalidate the reference  // TODO: assign here after converting vwf.js to a RequireJS module and listing "vwf/configuration" as a dependency
 

+ 1 - 3
public/web/index-app.js

@@ -743,7 +743,7 @@ class IndexApp {
                             db.get('documents').get(this._worldName.protoName).path(pathName).on((res)=>{
 
                                 if(res){
-
+                                
                                 
                                 console.log(res);
     
@@ -822,8 +822,6 @@ class IndexApp {
                     } else if (worldType == 'state') {
 
                         let pathNameInfo = 'savestate_/' + this._worldName.protoName+ '/' + this._worldName.stateName + '_info_vwf_json';
-                 
-
                         db.get('documents').get(this._worldName.protoName).path(pathNameInfo).on((res)=>{
                             if(res){