From 7be01d5b8f789576b8b74bf07824ed660d9339a1 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 10 Apr 2024 15:29:48 +0200 Subject: [PATCH] Fix: no more duplicate link showing up, avoid crash --- src/UI/SpecialVisualizations.ts | 34 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/UI/SpecialVisualizations.ts b/src/UI/SpecialVisualizations.ts index 21d5d3ede8..9f240a458b 100644 --- a/src/UI/SpecialVisualizations.ts +++ b/src/UI/SpecialVisualizations.ts @@ -89,6 +89,7 @@ import Toggle from "./Input/Toggle" import ImportReviewIdentity from "./Reviews/ImportReviewIdentity.svelte" import LinkedDataLoader from "../Logic/Web/LinkedDataLoader" import SplitRoadWizard from "./Popup/SplitRoadWizard.svelte" +import DynLink from "./Base/DynLink.svelte" class NearbyImageVis implements SpecialVisualization { // Class must be in SpecialVisualisations due to weird cyclical import that breaks the tests @@ -1236,22 +1237,19 @@ export default class SpecialVisualizations { download = undefined } const newTab = download === undefined && !href.startsWith("#") - return new VariableUiElement( - tagSource.map( - (tags) => - new SvelteUIElement(Link, { - text: Utils.SubstituteKeys(text, tags), - href: Utils.SubstituteKeys(href, tags).replaceAll( - / /g, - "%20" - ) /* Chromium based browsers eat the spaces */, - classnames, - download: Utils.SubstituteKeys(download, tags), - ariaLabel: Utils.SubstituteKeys(ariaLabel, tags), - newTab - }) - ) - ) + const textStore = tagSource.map(tags => Utils.SubstituteKeys(text, tags)) + const hrefStore = tagSource.map(tags => Utils.SubstituteKeys(href, tags).replaceAll( + / /g, + "%20" + ) /* Chromium based browsers eat the spaces */) + return new SvelteUIElement(DynLink, { + text:textStore, + href: hrefStore, + classnames: new ImmutableStore(classnames), + download: tagSource.map(tags => Utils.SubstituteKeys(download, tags)), + ariaLabel: tagSource.map(tags => Utils.SubstituteKeys(ariaLabel, tags)), + newTab: new ImmutableStore(newTab) + }) } }, { @@ -1309,6 +1307,10 @@ export default class SpecialVisualizations { } else { properties = tags[key] } + if(!properties){ + console.debug("Could not create a special visualization for multi(",args.join(", ")+")", "no properties found for object",feature.properties.id) + return undefined + } const elements = [] for (const property of properties) { const subsTr = new SvelteUIElement(SpecialTranslation, {