From f1ae5b21456b215eb11ffc049c41a5041e0a2853 Mon Sep 17 00:00:00 2001 From: Radek Czemerys Date: Fri, 26 Jun 2020 19:24:46 +0200 Subject: [PATCH] feature: improve ApplicationGroup --- app/assets/javascripts/ui_models/application_group.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/ui_models/application_group.ts b/app/assets/javascripts/ui_models/application_group.ts index f7a8459ed..bc6d3b5c0 100644 --- a/app/assets/javascripts/ui_models/application_group.ts +++ b/app/assets/javascripts/ui_models/application_group.ts @@ -11,11 +11,12 @@ import { ThemeManager } from '@/services'; import { AppState } from '@/ui_models/app_state'; +import { pull } from 'lodash'; type AppManagerChangeCallback = () => void export class ApplicationGroup { - + $compile: ng.ICompileService $rootScope: ng.IRootScopeService $timeout: ng.ITimeoutService @@ -50,8 +51,9 @@ export class ApplicationGroup { } if (this.applications.length === 0) { this.createDefaultApplication(); + } else { + this.notifyObserversOfAppChange(); } - this.notifyObserversOfAppChange(); } private createNewApplication() { @@ -121,6 +123,10 @@ export class ApplicationGroup { if (this.application) { callback(); } + + return () => { + pull( this.changeObservers, callback) + } } private notifyObserversOfAppChange() {