From c504890b93c262b31692e92cc8d58a42f0e106d4 Mon Sep 17 00:00:00 2001
From: fsdavid <daviti1@mail.com>
Date: Thu, 10 Dec 2020 11:56:50 +0100
Subject: [PATCH] Clear unsetClearViewByKey method

---
 src/atlasViewer/atlasViewer.component.ts      |  7 ------
 .../connectivityBrowser.component.ts          | 25 +++++++++++++++++--
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/src/atlasViewer/atlasViewer.component.ts b/src/atlasViewer/atlasViewer.component.ts
index 8388bf50d..38273ee96 100644
--- a/src/atlasViewer/atlasViewer.component.ts
+++ b/src/atlasViewer/atlasViewer.component.ts
@@ -404,13 +404,6 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit {
   }
 
   public unsetClearViewByKey(key: string){
-    // ToDo - In some cases (e.g. connectivity) expanded panel is not directly connected to the viewer
-    //  There are cases when panel is expanded but view is not affected, but when we close connectivity chip
-    //  sidebar panel should be collapse anyways. That's why additional store dispatch is added here.
-    this.store.dispatch({
-      type: SET_OVERRITEN_COLOR_MAP,
-      payload: false
-    })
     this.store.dispatch(
       ngViewerActionClearView({ payload: {
         [key]: false
diff --git a/src/ui/connectivityBrowser/connectivityBrowser.component.ts b/src/ui/connectivityBrowser/connectivityBrowser.component.ts
index e5fb85702..b7886618e 100644
--- a/src/ui/connectivityBrowser/connectivityBrowser.component.ts
+++ b/src/ui/connectivityBrowser/connectivityBrowser.component.ts
@@ -11,7 +11,7 @@ import {
 } from "@angular/core";
 import {select, Store} from "@ngrx/store";
 import {fromEvent, Observable, Subscription, Subject, combineLatest} from "rxjs";
-import {distinctUntilChanged, map} from "rxjs/operators";
+import {distinctUntilChanged, filter, map} from "rxjs/operators";
 import {
   CLEAR_CONNECTIVITY_REGION,
   SELECT_REGIONS,
@@ -158,6 +158,27 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
           }
         })
       )
+        
+      /** 
+       * Listen to of clear view entries 
+       * can come from within the component (when connectivity is not available for the dataset)
+       * --> do not collapse
+       * or outside (user clicks x in chip)
+       * --> collapse
+       */
+      this.subscriptions.push(
+        this.store$.pipe(
+          select(ngViewerSelectorClearViewEntries),
+          map(arr => arr.filter(v => v === CONNECTIVITY_NAME_PLATE)),
+          filter(arr => arr.length ===0),
+          distinctUntilChanged()
+        ).subscribe(() => {
+          if (!this.noDataReceived) {
+            this.setOpenState.emit(false)
+          }
+        })
+      )
+        
 
       this.subscriptions.push(this.overwrittenColorMap$.subscribe(ocm => {
         if (this.accordionIsExpanded && !ocm) {
@@ -185,6 +206,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
           )
         ).subscribe(([flag, connectedAreas]) => {
           if (connectedAreas === 'No data') {
+            this.noDataReceived = true
             return this.clearViewer()
           } else {
             this.store$.dispatch(
@@ -250,7 +272,6 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
         })
       )
       this.connectedAreas = []
-      this.noDataReceived = true
       this.connectivityNumberReceived.emit('0')
 
       return this.restoreDefaultColormap()
-- 
GitLab