From 1392d00c4807e828536c516d0d45a1c0c7c2cfac Mon Sep 17 00:00:00 2001
From: Xiao Gui <xgui3783@gmail.com>
Date: Thu, 23 May 2019 10:33:30 +0200
Subject: [PATCH] chore: fix mistake in user doc chore: clean up code, rename
 to clarify

---
 src/plugin_examples/plugin_api.md             |  2 +-
 src/services/state/viewerState.store.ts       | 66 ++++++++++++-------
 .../nehubaContainer.component.ts              |  2 +-
 .../nehubaViewer/nehubaViewer.component.ts    |  2 +-
 4 files changed, 44 insertions(+), 28 deletions(-)

diff --git a/src/plugin_examples/plugin_api.md b/src/plugin_examples/plugin_api.md
index 53794edc1..131e564e4 100644
--- a/src/plugin_examples/plugin_api.md
+++ b/src/plugin_examples/plugin_api.md
@@ -100,7 +100,7 @@ window.interactiveViewer
   - *remove3DLandmarks(IDs)* removes the landmarks by their IDs
   ```js
   window.interactiveViewer.viewerHandle
-    .remove3DLandmarks(['fzj-xg-jugex-1', 'fzj-xg-jugex-1'])
+    .remove3DLandmarks(['fzj-xg-jugex-1', 'fzj-xg-jugex-2'])
   /* removes the landmarks added above */
   ```
 
diff --git a/src/services/state/viewerState.store.ts b/src/services/state/viewerState.store.ts
index ce5b4c7f1..a8ff3fdaa 100644
--- a/src/services/state/viewerState.store.ts
+++ b/src/services/state/viewerState.store.ts
@@ -45,64 +45,80 @@ export function viewerState(
       const dedicatedView = state.dedicatedView
         ? state.dedicatedView.concat(action.dedicatedView)
         : [action.dedicatedView]
-      return Object.assign({},state,{
+      return {
+        ...state,
         dedicatedView 
-      })
+      }
     case UNLOAD_DEDICATED_LAYER:
-      return Object.assign({},state,{
+      return {
+        ...state,
         dedicatedView : state.dedicatedView
           ? state.dedicatedView.filter(dv => dv !== action.dedicatedView)
           : []
-      })
+      }
     case NEWVIEWER:
-      return Object.assign({},state,{
+      return {
+        ...state,
         templateSelected : action.selectTemplate,
         parcellationSelected : action.selectParcellation,
         regionsSelected : [],
         landmarksSelected : [],
         navigation : {},
         dedicatedView : null
-      })
+      }
     case FETCHED_TEMPLATE : {
-      return Object.assign({}, state, {
+      return {
+        ...state,
         fetchedTemplates: state.fetchedTemplates.concat(action.fetchedTemplate)
-      })
+      }
     }
     case CHANGE_NAVIGATION : {
-      return Object.assign({},state,{navigation : action.navigation})
+      return {
+        ...state,
+        navigation : action.navigation
+      }
     }
     case SELECT_PARCELLATION : {
-      return Object.assign({},state,{
+      return {
+        ...state,
         parcellationSelected : action.selectParcellation,
         regionsSelected : []
-      })
+      }
     }
     case DESELECT_REGIONS : {
-      return Object.assign({}, state, {
+      return {
+        ...state,
         regionsSelected : state.regionsSelected.filter(re => action.deselectRegions.findIndex(dRe => dRe.name === re.name) < 0)
-      })
+      }
     }
     case SELECT_REGIONS : {
-      return Object.assign({},state,{
-        regionsSelected : action.selectRegions.map(region=>Object.assign({},region,{
-          labelIndex : Number(region.labelIndex)
-        }))
-      })
+      return {
+        ...state,
+        regionsSelected : action.selectRegions.map(region => {
+          return {
+            ...region,
+            labelIndex: Number(region.labelIndex)
+          }
+        })
+      }
     }
     case DESELECT_LANDMARKS : {
-      return Object.assign({}, state, {
+      return {
+        ...state,
         landmarksSelected : state.landmarksSelected.filter(lm => action.deselectLandmarks.findIndex(dLm => dLm.name === lm.name) < 0)
-      })
+      }
     }
     case SELECT_LANDMARKS : {
-      return Object.assign({}, state, {
+      return {
+        ...state,
         landmarksSelected : action.landmarks
-      })
+      }
     }
     case USER_LANDMARKS : {
-      return Object.assign({}, state, {
-        userLandmarks : action.landmarks
-      })
+      return {
+        ...state,
+        userLandmarks: action.landmarks
+      } 
     }
     default :
       return state
diff --git a/src/ui/nehubaContainer/nehubaContainer.component.ts b/src/ui/nehubaContainer/nehubaContainer.component.ts
index 378494853..146d7a446 100644
--- a/src/ui/nehubaContainer/nehubaContainer.component.ts
+++ b/src/ui/nehubaContainer/nehubaContainer.component.ts
@@ -346,7 +346,7 @@ export class NehubaContainer implements OnInit, OnDestroy{
       ).subscribe(landmarks => {
         this.userLandmarks = landmarks
         if(this.nehubaViewer){
-          this.nehubaViewer.addUserLandmarks(landmarks)
+          this.nehubaViewer.updateUserLandmarks(landmarks)
         }
       })
     )
diff --git a/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts b/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts
index dd34a2bc2..226a18e0f 100644
--- a/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts
+++ b/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts
@@ -482,7 +482,7 @@ export class NehubaViewerUnit implements OnDestroy{
   }
 
   // TODO single landmark for user landmark
-  public addUserLandmarks(landmarks:any[]){
+  public updateUserLandmarks(landmarks:any[]){
     if(!this.nehubaViewer)
       return
     this.workerService.worker.postMessage({
-- 
GitLab