diff --git a/src/Logic/MetaTagging.ts b/src/Logic/MetaTagging.ts index 6477bbac7f..da5ac32fae 100644 --- a/src/Logic/MetaTagging.ts +++ b/src/Logic/MetaTagging.ts @@ -25,7 +25,7 @@ export default class MetaTagging { >() constructor(state: { - readonly selectedElementAndLayer: Store<{ feature: Feature; layer: LayerConfig }> + readonly selectedElement: Store readonly layout: LayoutConfig readonly osmObjectDownloader: OsmObjectDownloader readonly perLayer: ReadonlyMap @@ -61,7 +61,8 @@ export default class MetaTagging { }) } - state.selectedElementAndLayer.addCallbackAndRunD(({ feature, layer }) => { + state.selectedElement.addCallbackAndRunD((feature) => { + const layer = state.layout.getMatchingLayer(feature.properties) // Force update the tags of the currently selected element MetaTagging.addMetatags( [feature], diff --git a/src/Logic/State/UserSettingsMetaTagging.ts b/src/Logic/State/UserSettingsMetaTagging.ts index 6e568c5c32..33a5ae85b5 100644 --- a/src/Logic/State/UserSettingsMetaTagging.ts +++ b/src/Logic/State/UserSettingsMetaTagging.ts @@ -1,42 +1,14 @@ import { Utils } from "../../Utils" /** This code is autogenerated - do not edit. Edit ./assets/layers/usersettings/usersettings.json instead */ export class ThemeMetaTagging { - public static readonly themeName = "usersettings" + public static readonly themeName = "usersettings" - public metaTaggging_for_usersettings(feat: { properties: Record }) { - Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_md", () => - feat.properties._description - .match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/) - ?.at(1) - ) - Utils.AddLazyProperty( - feat.properties, - "_d", - () => feat.properties._description?.replace(/</g, "<")?.replace(/>/g, ">") ?? "" - ) - Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_a", () => - ((feat) => { - const e = document.createElement("div") - e.innerHTML = feat.properties._d - return Array.from(e.getElementsByTagName("a")).filter( - (a) => a.href.match(/mastodon|en.osm.town/) !== null - )[0]?.href - })(feat) - ) - Utils.AddLazyProperty(feat.properties, "_mastodon_link", () => - ((feat) => { - const e = document.createElement("div") - e.innerHTML = feat.properties._d - return Array.from(e.getElementsByTagName("a")).filter( - (a) => a.getAttribute("rel")?.indexOf("me") >= 0 - )[0]?.href - })(feat) - ) - Utils.AddLazyProperty( - feat.properties, - "_mastodon_candidate", - () => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a - ) - feat.properties["__current_backgroun"] = "initial_value" - } -} + public metaTaggging_for_usersettings(feat: {properties: Record}) { + Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_md', () => feat.properties._description.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)?.at(1) ) + Utils.AddLazyProperty(feat.properties, '_d', () => feat.properties._description?.replace(/</g,'<')?.replace(/>/g,'>') ?? '' ) + Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_a', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.href.match(/mastodon|en.osm.town/) !== null)[0]?.href }) (feat) ) + Utils.AddLazyProperty(feat.properties, '_mastodon_link', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.getAttribute("rel")?.indexOf('me') >= 0)[0]?.href})(feat) ) + Utils.AddLazyProperty(feat.properties, '_mastodon_candidate', () => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a ) + feat.properties['__current_backgroun'] = 'initial_value' + } +} \ No newline at end of file diff --git a/src/Logic/Web/ThemeViewStateHashActor.ts b/src/Logic/Web/ThemeViewStateHashActor.ts index 129de09ced..817d7173a2 100644 --- a/src/Logic/Web/ThemeViewStateHashActor.ts +++ b/src/Logic/Web/ThemeViewStateHashActor.ts @@ -115,7 +115,6 @@ export default class ThemeViewStateHashActor { "" ) selectedElement.setData(found) - state.selectedLayer.setData(layer) return true } diff --git a/src/Models/ThemeViewState.ts b/src/Models/ThemeViewState.ts index f5c5762811..8e25522827 100644 --- a/src/Models/ThemeViewState.ts +++ b/src/Models/ThemeViewState.ts @@ -84,7 +84,6 @@ export default class ThemeViewState implements SpecialVisualizationState { readonly osmConnection: OsmConnection readonly selectedElement: UIEventSource - readonly selectedElementAndLayer: Store<{ feature: Feature; layer: LayerConfig }> readonly mapProperties: MapLibreAdaptor & MapProperties & ExportableMap readonly osmObjectDownloader: OsmObjectDownloader @@ -179,18 +178,6 @@ export default class ThemeViewState implements SpecialVisualizationState { this.mapProperties.allowRotating.setData(fixated !== "yes") }) this.selectedElement = new UIEventSource(undefined, "Selected element") - this.selectedLayer = new UIEventSource(undefined, "Selected layer") - - this.selectedElementAndLayer = this.selectedElement.mapD( - (feature) => { - const layer = this.selectedLayer.data - if (!layer) { - return undefined - } - return { layer, feature } - }, - [this.selectedLayer] - ) this.geolocation = new GeoLocationHandler( geolocationState, @@ -434,7 +421,6 @@ export default class ThemeViewState implements SpecialVisualizationState { doShowLayer, metaTags: this.userRelatedState.preferencesAsTags, selectedElement: this.selectedElement, - selectedLayer: this.selectedLayer, fetchStore: (id) => this.featureProperties.getStore(id), }) }) @@ -442,14 +428,12 @@ export default class ThemeViewState implements SpecialVisualizationState { } public openNewDialog() { - this.selectedLayer.setData(undefined) this.selectedElement.setData(undefined) const { lon, lat } = this.mapProperties.location.data const feature = this.lastClickObject.createFeature(lon, lat) this.featureProperties.trackFeature(feature) this.selectedElement.setData(feature) - this.selectedLayer.setData(this.newPointDialog.layerDef) } /** @@ -514,14 +498,12 @@ export default class ThemeViewState implements SpecialVisualizationState { } const layer = this.layout.getMatchingLayer(toSelect.properties) this.selectedElement.setData(undefined) - this.selectedLayer.setData(layer) this.selectedElement.setData(toSelect) }) return } const layer = this.layout.getMatchingLayer(toSelect.properties) this.selectedElement.setData(undefined) - this.selectedLayer.setData(layer) this.selectedElement.setData(toSelect) } @@ -750,8 +732,7 @@ export default class ThemeViewState implements SpecialVisualizationState { doShowLayer: flayer.isDisplayed, layer: flayer.layerDef, metaTags: this.userRelatedState.preferencesAsTags, - selectedElement: this.selectedElement, - selectedLayer: this.selectedLayer, + selectedElement: this.selectedElement }) }) } @@ -765,7 +746,6 @@ export default class ThemeViewState implements SpecialVisualizationState { console.trace("Unselected") // We did _unselect_ an item - we always remove the lastclick-object this.lastClickObject.features.setData([]) - this.selectedLayer.setData(undefined) this.focusOnMap() } }) diff --git a/src/UI/Map/ShowDataLayerOptions.ts b/src/UI/Map/ShowDataLayerOptions.ts index 39569280b7..bbd7135518 100644 --- a/src/UI/Map/ShowDataLayerOptions.ts +++ b/src/UI/Map/ShowDataLayerOptions.ts @@ -14,11 +14,6 @@ export interface ShowDataLayerOptions { */ selectedElement?: UIEventSource - /** - * When a feature of this layer is tapped, the layer will be marked - */ - selectedLayer?: UIEventSource - /** * If set, zoom to the features when initially loaded and when they are changed */ diff --git a/src/UI/Popup/ImportButtons/ConflateImportFlowState.ts b/src/UI/Popup/ImportButtons/ConflateImportFlowState.ts index 5c68c40461..da4adc8177 100644 --- a/src/UI/Popup/ImportButtons/ConflateImportFlowState.ts +++ b/src/UI/Popup/ImportButtons/ConflateImportFlowState.ts @@ -53,7 +53,6 @@ export default class ConflateImportFlowState extends ImportFlow - /** - * Works together with 'selectedElement' to indicate what properties should be displayed - * @deprecated - * - * No need to set this anymore - */ - readonly selectedLayer: UIEventSource - readonly selectedElementAndLayer: Store<{ feature: Feature; layer: LayerConfig }> readonly favourites: FavouritesFeatureSource