浏览代码

[assist] Only fetch the documents when that panel becomes visible

Johan Ahlen 9 年之前
父节点
当前提交
2ffd093

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/assist/assistHelper.js

@@ -782,7 +782,7 @@
     if (queue.length > 1) {
       return;
     }
-    
+
     $.post(options.url, {
       notebook: {},
       snippet: ko.mapping.toJSON({

+ 13 - 3
desktop/core/src/desktop/templates/assist.mako

@@ -769,7 +769,19 @@ from desktop.views import _ko
 
         self.visible = ko.observable(options.visible);
         options.assistHelper.withTotalStorage('assist', 'showingPanel_' + self.type, self.visible, false, options.visible);
-        self.templateName = 'assist-' + self.type + '-inner-panel'
+        self.templateName = 'assist-' + self.type + '-inner-panel';
+
+        var loadWhenVisible = function () {
+          if (! self.visible()) {
+            return;
+          }
+          if (self.type === 'documents' && !self.panelData.activeEntry().loaded()) {
+            self.panelData.activeEntry().load();
+          }
+        };
+
+        self.visible.subscribe(loadWhenVisible);
+        loadWhenVisible();
       }
 
       /**
@@ -908,8 +920,6 @@ from desktop.views import _ko
             type: 'directory'
           }
         }));
-
-        self.activeEntry().load();
       }
 
       /**