From b0d394797b32a15ac5394ec7310fab179ddc5ea0 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Mon, 29 Jan 2024 18:09:25 +0100 Subject: [PATCH] Refactoring: remove selectedLayer from titleHandler --- src/Logic/Actors/TitleHandler.ts | 11 ++++++----- src/Models/ThemeViewState.ts | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Logic/Actors/TitleHandler.ts b/src/Logic/Actors/TitleHandler.ts index c5b8dfea0..9f6be82b3 100644 --- a/src/Logic/Actors/TitleHandler.ts +++ b/src/Logic/Actors/TitleHandler.ts @@ -12,20 +12,21 @@ import { SpecialVisualizationState } from "../../UI/SpecialVisualization" export default class TitleHandler { constructor( selectedElement: Store, - selectedLayer: Store, allElements: FeaturePropertiesStore, state: SpecialVisualizationState ) { const currentTitle: Store = selectedElement.map( (selected) => { const defaultTitle = state.layout?.title?.txt ?? "MapComplete" - - if (selected === undefined || selectedLayer.data === undefined) { + if (selected === undefined) { + return defaultTitle + } + const layer = state.layout.getMatchingLayer(selected.properties) + if (layer === undefined) { return defaultTitle } const tags = selected.properties - const layer = selectedLayer.data if (layer.title === undefined) { return defaultTitle } @@ -43,7 +44,7 @@ export default class TitleHandler { defaultTitle ) }, - [Locale.language, selectedLayer] + [Locale.language] ) currentTitle.addCallbackAndRunD((title) => { diff --git a/src/Models/ThemeViewState.ts b/src/Models/ThemeViewState.ts index be24e39e7..14eed5ca3 100644 --- a/src/Models/ThemeViewState.ts +++ b/src/Models/ThemeViewState.ts @@ -790,7 +790,7 @@ export default class ThemeViewState implements SpecialVisualizationState { }) new ThemeViewStateHashActor(this) new MetaTagging(this) - new TitleHandler(this.selectedElement, this.selectedLayer, this.featureProperties, this) + new TitleHandler(this.selectedElement, this.featureProperties, this) new ChangeToElementsActor(this.changes, this.featureProperties) new PendingChangesUploader(this.changes, this.selectedElement) new SelectedElementTagsUpdater(this)