Răsfoiți Sursa

HUE-7205 [editor] Fix leaking interval in logScroller

Johan Ahlen 8 ani în urmă
părinte
comite
193a4c221e

+ 5 - 4
desktop/core/src/desktop/static/desktop/js/hue.utils.js

@@ -271,11 +271,12 @@ if (!('addRule' in CSSStyleSheet.prototype)) {
     var $el = selector instanceof jQuery ? selector: $(selector);
     if (condition($el)) {
       callback($el);
-    }
-    else {
-      window.setTimeout(function () {
+    } else {
+      window.clearTimeout($el.data('waitForRenderTimeout'));
+      var waitForRenderTimeout = window.setTimeout(function () {
         hueUtils.waitForRendered(selector, condition, callback);
-      }, timeout || 100)
+      }, timeout || 100);
+      $el.data('waitForRenderTimeout', waitForRenderTimeout);
     }
   };
 

+ 5 - 2
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -1025,9 +1025,12 @@
         allBindings().logScrollerVisibilityEvent.subscribe(function () {
           window.setTimeout(autoLogScroll, 0);
         });
+      } else {
+        hueUtils.waitForRendered(element, function(el) { return el.is(':visible') }, autoLogScroll, 300);
+        ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
+          window.clearTimeout($element.data('waitForRenderTimeout'));
+        });
       }
-
-      hueUtils.waitForRendered(element, function(el){ return el.is(':visible') }, autoLogScroll);
     }
   };