Ver código fonte

HUE-9100 [editor] Delay execute until session create is completed

https://github.com/cloudera/hue/commit/f29efd07cb5ddd4571bfc9bec0e5bf7ecc518d22, https://review.cloudera.org/r/5715/ had introduced a delay in createSession in order to have syntax appear highlighting faster. Many changes have happen since and it's no longer an issue. Snippet.init() potentially calls execute if a statement is available and we wait until createSession is completed, before calling init(). This change is not needed in notebook 2, because execution requires a session. In notebook 1, execution is not dependent on getting a session first.
Jean-Francois Desjeans Gauthier 6 anos atrás
pai
commit
9247744d1c

+ 8 - 5
desktop/core/src/desktop/js/apps/notebook/notebook.js

@@ -324,14 +324,17 @@ class Notebook {
       const _snippet = new Snippet(vm, self, snippet);
       self.snippets.push(_snippet);
 
+      const deferred = $.Deferred().done(() => {
+        _snippet.init();
+      });
       if (self.getSession(_snippet.type()) == null && typeof skipSession == 'undefined') {
-        window.setTimeout(() => {
-          _snippet.status('loading');
-          self.createSession(new Session(vm, { type: _snippet.type() }));
-        }, 200);
+        self.createSession(new Session(vm, { type: _snippet.type() }), () => {
+          deferred.resolve();
+        });
+      } else {
+        deferred.resolve();
       }
 
-      _snippet.init();
       return _snippet;
     };