]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/services/refresh-interval.service.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / services / refresh-interval.service.ts
index 0627d78ecf028315fa9a205296d340d43736f96a..03aa3b8a56ad1f6cb86525f06c9df50a325c67f6 100644 (file)
@@ -1,4 +1,4 @@
-import { Injectable, OnDestroy } from '@angular/core';
+import { Injectable, NgZone, OnDestroy } from '@angular/core';
 
 import { BehaviorSubject, interval, Subscription } from 'rxjs';
 
@@ -13,7 +13,7 @@ export class RefreshIntervalService implements OnDestroy {
   // Observable streams
   intervalData$ = this.intervalDataSource.asObservable();
 
-  constructor() {
+  constructor(private ngZone: NgZone) {
     const initialInterval = parseInt(sessionStorage.getItem('dashboard_interval'), 10) || 5000;
     this.setRefreshInterval(initialInterval);
   }
@@ -25,9 +25,13 @@ export class RefreshIntervalService implements OnDestroy {
     if (this.intervalSubscription) {
       this.intervalSubscription.unsubscribe();
     }
-    this.intervalSubscription = interval(this.intervalTime).subscribe(() =>
-      this.intervalDataSource.next(this.intervalTime)
-    );
+    this.ngZone.runOutsideAngular(() => {
+      this.intervalSubscription = interval(this.intervalTime).subscribe(() =>
+        this.ngZone.run(() => {
+          this.intervalDataSource.next(this.intervalTime);
+        })
+      );
+    });
   }
 
   getRefreshInterval() {