From c3c8cd3f4d1bd58eb98740fc86f500a17ea84024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 28 Jan 2019 18:19:12 +0100 Subject: [PATCH] Fix for annotations not clearing when switching dashboards, fixes #15063 --- public/app/features/annotations/annotations_srv.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/public/app/features/annotations/annotations_srv.ts b/public/app/features/annotations/annotations_srv.ts index 4fe6e10b2cf..1f580319188 100644 --- a/public/app/features/annotations/annotations_srv.ts +++ b/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) {