Fix: no more duplicate link showing up, avoid crash

This commit is contained in:
Pieter Vander Vennet 2024-04-10 15:29:48 +02:00
parent 0d085c92cf
commit 7be01d5b8f

View file

@ -89,6 +89,7 @@ import Toggle from "./Input/Toggle"
import ImportReviewIdentity from "./Reviews/ImportReviewIdentity.svelte" import ImportReviewIdentity from "./Reviews/ImportReviewIdentity.svelte"
import LinkedDataLoader from "../Logic/Web/LinkedDataLoader" import LinkedDataLoader from "../Logic/Web/LinkedDataLoader"
import SplitRoadWizard from "./Popup/SplitRoadWizard.svelte" import SplitRoadWizard from "./Popup/SplitRoadWizard.svelte"
import DynLink from "./Base/DynLink.svelte"
class NearbyImageVis implements SpecialVisualization { class NearbyImageVis implements SpecialVisualization {
// Class must be in SpecialVisualisations due to weird cyclical import that breaks the tests // Class must be in SpecialVisualisations due to weird cyclical import that breaks the tests
@ -1236,22 +1237,19 @@ export default class SpecialVisualizations {
download = undefined download = undefined
} }
const newTab = download === undefined && !href.startsWith("#") const newTab = download === undefined && !href.startsWith("#")
return new VariableUiElement( const textStore = tagSource.map(tags => Utils.SubstituteKeys(text, tags))
tagSource.map( const hrefStore = tagSource.map(tags => Utils.SubstituteKeys(href, tags).replaceAll(
(tags) =>
new SvelteUIElement(Link, {
text: Utils.SubstituteKeys(text, tags),
href: Utils.SubstituteKeys(href, tags).replaceAll(
/ /g, / /g,
"%20" "%20"
) /* Chromium based browsers eat the spaces */, ) /* Chromium based browsers eat the spaces */)
classnames, return new SvelteUIElement(DynLink, {
download: Utils.SubstituteKeys(download, tags), text:textStore,
ariaLabel: Utils.SubstituteKeys(ariaLabel, tags), href: hrefStore,
newTab 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 { } else {
properties = <any>tags[key] properties = <any>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 = [] const elements = []
for (const property of properties) { for (const property of properties) {
const subsTr = new SvelteUIElement(SpecialTranslation, { const subsTr = new SvelteUIElement(SpecialTranslation, {