From 6b4f3a6bf52f9c6bac5028dd458a2edad99207f4 Mon Sep 17 00:00:00 2001 From: Xiao Gui <xgui3783@gmail.com> Date: Mon, 26 Aug 2019 12:33:15 +0200 Subject: [PATCH] bugfix: persist layout changes on change of template --- .../nehubaContainer.component.ts | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/ui/nehubaContainer/nehubaContainer.component.ts b/src/ui/nehubaContainer/nehubaContainer.component.ts index 3f766cdd6..85e32cf11 100644 --- a/src/ui/nehubaContainer/nehubaContainer.component.ts +++ b/src/ui/nehubaContainer/nehubaContainer.component.ts @@ -142,6 +142,7 @@ export class NehubaContainer implements OnInit, OnDestroy{ private viewPanels: [HTMLElement, HTMLElement, HTMLElement, HTMLElement] = [null, null, null, null] public panelMode$: Observable<string> + private redrawLayout$: Observable<[string, string]> constructor( private constantService : AtlasViewerConstantsServices, @@ -162,6 +163,25 @@ export class NehubaContainer implements OnInit, OnDestroy{ filter(() => isDefined(this.nehubaViewer) && isDefined(this.nehubaViewer.nehubaViewer)) ) + this.redrawLayout$ = this.store.pipe( + select('ngViewerState'), + select('nehubaReady'), + distinctUntilChanged(), + filter(v => !!v), + switchMapTo(combineLatest( + this.store.pipe( + select('ngViewerState'), + select('panelMode'), + distinctUntilChanged() + ), + this.store.pipe( + select('ngViewerState'), + select('panelOrder'), + distinctUntilChanged() + ) + )) + ) + this.nehubaViewerFactory = this.csf.resolveComponentFactory(NehubaViewerUnit) this.newViewer$ = this.store.pipe( @@ -431,19 +451,8 @@ export class NehubaContainer implements OnInit, OnDestroy{ ) this.subscriptions.push( - combineLatest( - this.store.pipe( - select('ngViewerState'), - select('panelMode'), - distinctUntilChanged() - ), - this.store.pipe( - select('ngViewerState'), - select('panelOrder'), - distinctUntilChanged() - ) - ).subscribe(([mode, panelOrder]) => { - const viewPanels = panelOrder.split('').map(v => Number(v)).map(idx => this.viewPanels[idx]) + this.redrawLayout$.subscribe(([mode, panelOrder]) => { + const viewPanels = panelOrder.split('').map(v => Number(v)).map(idx => this.viewPanels[idx]) as [HTMLElement, HTMLElement, HTMLElement, HTMLElement] /** * TODO be smarter with event stream */ -- GitLab