Преглед изворни кода

HUE-6087 [core] Pause intervals when the app is in background in Hue 4

Enrico Berti пре 8 година
родитељ
комит
6b47340
1 измењених фајлова са 8 додато и 0 уклоњено
  1. 8 0
      desktop/core/src/desktop/templates/hue.mako

+ 8 - 0
desktop/core/src/desktop/templates/hue.mako

@@ -725,6 +725,7 @@ ${ assist.assistPanel() }
 
         var loadedJs = [];
         var loadedCss = [];
+        var loadedApps = [];
 
         $('script[src]').each(function(){
           loadedJs.push($(this).attr('src'));
@@ -766,7 +767,13 @@ ${ assist.assistPanel() }
             hueUtils.removeURLParameter('type');
           }
           self.isLoadingEmbeddable(true);
+          loadedApps.forEach(function (app) {
+            window.pauseAppIntervals(app);
+          });
           if (typeof self.embeddable_cache[newVal] === 'undefined') {
+            if (loadedApps.indexOf(newVal) == -1){
+              loadedApps.push(newVal);
+            }
             $.ajax({
               url: EMBEDDABLE_PAGE_URLS[newVal] + self.extraEmbeddableURLParams(),
               beforeSend: function (xhr) {
@@ -786,6 +793,7 @@ ${ assist.assistPanel() }
           } else {
             self.isLoadingEmbeddable(false);
           }
+          window.resumeAppIntervals(newVal);
           $('.embeddable').hide();
           $('#embeddable_' + newVal).insertBefore($('.embeddable:first')).show();
         });