Browse Source

Fix for annotations not clearing when switching dashboards, fixes #15063

Torkel Ödegaard 7 years ago
parent
commit
c3c8cd3f4d
1 changed files with 9 additions and 5 deletions
  1. 9 5
      public/app/features/annotations/annotations_srv.ts

+ 9 - 5
public/app/features/annotations/annotations_srv.ts

@@ -21,12 +21,16 @@ export class AnnotationsSrv {
   constructor(private $rootScope, private $q, private datasourceSrv, private backendSrv, private timeSrv) {}
 
   init(dashboard: DashboardModel) {
+    // always clearPromiseCaches when loading new dashboard
+    this.clearPromiseCaches();
     // clear promises on refresh events
-    dashboard.on('refresh', () => {
-      this.globalAnnotationsPromise = null;
-      this.alertStatesPromise = null;
-      this.datasourcePromises = null;
-    });
+    dashboard.on('refresh', this.clearPromiseCaches.bind(this));
+  }
+
+  clearPromiseCaches() {
+    this.globalAnnotationsPromise = null;
+    this.alertStatesPromise = null;
+    this.datasourcePromises = null;
   }
 
   getAnnotations(options) {