diff --git a/libs/asset-viewer/src/lib/components/map/map.component.ts b/libs/asset-viewer/src/lib/components/map/map.component.ts index 2a01bf50..968e80c1 100644 --- a/libs/asset-viewer/src/lib/components/map/map.component.ts +++ b/libs/asset-viewer/src/lib/components/map/map.component.ts @@ -21,7 +21,8 @@ import { selectAssetSearchPolygon, selectAssetSearchResultData, selectCurrentAssetDetail, - selectHasDefaultFilters, + selectHasNoActiveFilters, + selectIsSearchQueryEmpty, selectStudies, } from '../../state/asset-search/asset-search.selector'; import { AppStateWithMapControl } from '../../state/map-control/map-control.reducer'; @@ -129,7 +130,7 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy { this.controller.addControl(this.controls.draw); this.subscription.add( - this.store.select(selectHasDefaultFilters).subscribe((hasDefaultFilters) => { + this.store.select(selectIsSearchQueryEmpty).subscribe((hasDefaultFilters) => { if (hasDefaultFilters) { this.controls.zoom.resetZoom(); } @@ -155,8 +156,8 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy { private initializeStoreBindings() { this.subscription.add( - this.store.select(selectHasDefaultFilters).subscribe((showStudies) => { - this.controller.setShowHeatmap(showStudies); + this.store.select(selectHasNoActiveFilters).subscribe((basDefaultFilters) => { + this.controller.setShowHeatmap(basDefaultFilters); }) ); this.subscription.add( diff --git a/libs/asset-viewer/src/lib/state/asset-search/asset-search.effects.ts b/libs/asset-viewer/src/lib/state/asset-search/asset-search.effects.ts index f7a37778..0d280551 100644 --- a/libs/asset-viewer/src/lib/state/asset-search/asset-search.effects.ts +++ b/libs/asset-viewer/src/lib/state/asset-search/asset-search.effects.ts @@ -18,7 +18,7 @@ import { selectAssetSearchIsInitialized, selectAssetSearchQuery, selectCurrentAssetDetail, - selectHasDefaultFilters, + selectIsSearchQueryEmpty, selectSearchLoadingState, selectStudies, } from './asset-search.selector'; @@ -221,7 +221,7 @@ export class AssetSearchEffects { this.actions$.pipe( ofType(actions.updateResults), map(({ results }) => results.page.total !== 0), - withLatestFrom(this.store.select(selectHasDefaultFilters)), + withLatestFrom(this.store.select(selectIsSearchQueryEmpty)), map(([hasResults, hasNoFilters]) => !hasResults || hasNoFilters ? actions.closeResults() : actions.openResults() ) diff --git a/libs/asset-viewer/src/lib/state/asset-search/asset-search.selector.ts b/libs/asset-viewer/src/lib/state/asset-search/asset-search.selector.ts index 03a02c80..197042a6 100644 --- a/libs/asset-viewer/src/lib/state/asset-search/asset-search.selector.ts +++ b/libs/asset-viewer/src/lib/state/asset-search/asset-search.selector.ts @@ -60,12 +60,16 @@ export const selectAssetSearchTotalResults = createSelector(assetSearchFeature, export const selectCurrentAssetDetail = createSelector(assetSearchFeature, (state) => state.currentAsset); export const selectStudies = createSelector(assetSearchFeature, (state) => state.studies); -export const selectHasDefaultFilters = createSelector( +export const selectHasNoActiveFilters = createSelector(assetSearchFeature, ({ query }) => hasNoActiveFilters(query)); + +export const selectIsSearchQueryEmpty = createSelector( assetSearchFeature, - ({ query, currentAsset }) => - currentAsset == null && Object.values(query).every((value) => value === undefined || value == false) + ({ query, currentAsset }) => currentAsset == null && hasNoActiveFilters(query) ); +const hasNoActiveFilters = (query: AssetSearchQuery): boolean => + Object.values(query).every((value) => value === undefined || value == false); + export const selectCurrentAssetDetailVM = createSelector( fromAppShared.selectRDReferenceData, selectCurrentAssetDetail,