diff --git a/docs/releases/v2.11.1.md b/docs/releases/v2.11.1.md index 7c187df69ab20e2bf1aeb6b1606076fc9cfe7367..dd1b4527b946752e42337b60a83c353b2108b912 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 a76fd1f9f2e8fc45335a5b3695c65bb68322dfef..525df7f1fdc00f7528bdfbbc210a547db3b738ac 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 40e84c234c4bca8d7eb7fece2c2c999ab249629f..12adc4b974fb893cef495e9310a5b990966478d4 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 5d4986ad5965117705e6d1aa869407fabdbd8a65..7fd81d8ae1252522deba3c4f589eda32d61513e7 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 +}