From f1ae5b21456b215eb11ffc049c41a5041e0a2853 Mon Sep 17 00:00:00 2001 From: Radek Czemerys Date: Fri, 26 Jun 2020 19:24:46 +0200 Subject: [PATCH 1/3] 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() { From 34505deddc81ae1d9dfb51b9fee12fa391ae1e1b Mon Sep 17 00:00:00 2001 From: Radek Czemerys Date: Fri, 26 Jun 2020 19:27:24 +0200 Subject: [PATCH 2/3] chore: remove whitespace --- app/assets/javascripts/ui_models/application_group.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/ui_models/application_group.ts b/app/assets/javascripts/ui_models/application_group.ts index bc6d3b5c0..582565820 100644 --- a/app/assets/javascripts/ui_models/application_group.ts +++ b/app/assets/javascripts/ui_models/application_group.ts @@ -125,7 +125,7 @@ export class ApplicationGroup { } return () => { - pull( this.changeObservers, callback) + pull(this.changeObservers, callback) } } From 3b3c2d6fe44f5026bac4a4deead3047c1d0dc7f4 Mon Sep 17 00:00:00 2001 From: Radek Czemerys Date: Mon, 29 Jun 2020 11:35:40 +0200 Subject: [PATCH 3/3] fix: don't use lodash pull --- app/assets/javascripts/ui_models/application_group.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/ui_models/application_group.ts b/app/assets/javascripts/ui_models/application_group.ts index 582565820..adb25d3ef 100644 --- a/app/assets/javascripts/ui_models/application_group.ts +++ b/app/assets/javascripts/ui_models/application_group.ts @@ -11,7 +11,6 @@ import { ThemeManager } from '@/services'; import { AppState } from '@/ui_models/app_state'; -import { pull } from 'lodash'; type AppManagerChangeCallback = () => void @@ -125,7 +124,8 @@ export class ApplicationGroup { } return () => { - pull(this.changeObservers, callback) + const indexOfObserver = this.changeObservers.indexOf(callback); + this.changeObservers.splice(indexOfObserver, 1); } }