From a5d4bcfaf597fc1a6f880dd97de63bc2adbc7497 Mon Sep 17 00:00:00 2001 From: Xiao Gui <xgui3783@gmail.com> Date: Thu, 1 Jun 2023 09:27:36 +0200 Subject: [PATCH] fix: on t/p/a selection, clear curr selected feat --- docs/releases/v2.11.1.md | 1 + src/state/atlasSelection/util.ts | 6 ++---- src/state/index.ts | 1 + src/state/userInteraction/effects.ts | 26 +++++++++++++++++++++----- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/docs/releases/v2.11.1.md b/docs/releases/v2.11.1.md index 7c187df69..dd1b4527b 100644 --- a/docs/releases/v2.11.1.md +++ b/docs/releases/v2.11.1.md @@ -9,6 +9,7 @@ ## Bugfixes - Fixed point assignment full table not showing +- On template/parcellation/atlas change, clear currently selected feature ## Behind the scenes diff --git a/src/state/atlasSelection/util.ts b/src/state/atlasSelection/util.ts index a76fd1f9f..525df7f1f 100644 --- a/src/state/atlasSelection/util.ts +++ b/src/state/atlasSelection/util.ts @@ -1,8 +1,6 @@ import { createSelector, select } from "@ngrx/store"; -import { forkJoin, of, pipe } from "rxjs"; -import { distinctUntilChanged, map, switchMap } from "rxjs/operators"; -import { SAPI } from "src/atlasComponents/sapi"; -import { translateV3Entities } from "src/atlasComponents/sapi/translateV3" +import { pipe } from "rxjs"; +import { distinctUntilChanged, map } from "rxjs/operators"; import { SxplrAtlas, SxplrParcellation, SxplrTemplate } from "src/atlasComponents/sapi/sxplrTypes"; import { jsonEqual } from "src/util/json"; import * as selectors from "./selectors" diff --git a/src/state/index.ts b/src/state/index.ts index 40e84c234..12adc4b97 100644 --- a/src/state/index.ts +++ b/src/state/index.ts @@ -71,6 +71,7 @@ export function getStoreEffects() { plugins.Effects, atlasSelection.Effect, userInterface.Effects, + userInteraction.Effect, ] } diff --git a/src/state/userInteraction/effects.ts b/src/state/userInteraction/effects.ts index 5d4986ad5..7fd81d8ae 100644 --- a/src/state/userInteraction/effects.ts +++ b/src/state/userInteraction/effects.ts @@ -1,17 +1,33 @@ import { Injectable } from "@angular/core"; import { Actions, createEffect, ofType } from "@ngrx/effects"; -import * as atlasSelectionActions from "../atlasSelection/actions" import * as userInterface from "../userInterface" -import { mapTo } from "rxjs/operators"; +import * as atlasSelection from "../atlasSelection" +import * as actions from "./actions" +import { filter, map, mapTo, skip } from "rxjs/operators"; +import { Store } from "@ngrx/store"; @Injectable() export class Effect { onStandAloneVolumesExistCloseMatDrawer = createEffect(() => this.action.pipe( - ofType(atlasSelectionActions.clearStandAloneVolumes), + ofType(atlasSelection.actions.clearStandAloneVolumes), mapTo(userInterface.actions.closeSidePanel()) )) - constructor(private action: Actions){ + #distinctATP$ = this.store.pipe( + atlasSelection.fromRootStore.distinctATP(), + ) + + onATPUpdateUnselectFeature = createEffect(() => this.#distinctATP$.pipe( + filter(v => !!v.atlas && !!v.parcellation && !!v.template), + /** + * First non empty emit would be from selecting atlas. + * So ignore it. + */ + skip(1), + map(() => actions.clearShownFeature()) + )) + + constructor(private action: Actions, private store: Store){ } -} \ No newline at end of file +} -- GitLab