diff --git a/src/UI/SpecialVisualisations/WebAndCommunicationSpecialVisualisations.ts b/src/UI/SpecialVisualisations/WebAndCommunicationSpecialVisualisations.ts index f3e48173f..e371d8e02 100644 --- a/src/UI/SpecialVisualisations/WebAndCommunicationSpecialVisualisations.ts +++ b/src/UI/SpecialVisualisations/WebAndCommunicationSpecialVisualisations.ts @@ -24,8 +24,8 @@ export class WebAndCommunicationSpecialVisualisations { { name: "key", doc: "The attribute-name containing the link", - required: true, - }, + required: true + } ], constr( @@ -35,7 +35,7 @@ export class WebAndCommunicationSpecialVisualisations { ): BaseUIElement { const key = argument[0] return new SvelteUIElement(FediverseLink, { key, tags, state }) - }, + } }, { funcName: "wikipedia", @@ -45,8 +45,8 @@ export class WebAndCommunicationSpecialVisualisations { { name: "keyToShowWikipediaFor", doc: "Use the wikidata entry from this key to show the wikipedia article for. Multiple keys can be given (separated by ';'), in which case the first matching value is used", - defaultValue: "wikidata;wikipedia", - }, + defaultValue: "wikidata;wikipedia" + } ], needsUrls: [...Wikidata.neededUrls, ...Wikipedia.neededUrls], @@ -59,9 +59,9 @@ export class WebAndCommunicationSpecialVisualisations { return tags[key]?.split(";")?.map((id) => id.trim()) ?? [] }) return new SvelteUIElement(WikipediaPanel, { - wikiIds, + wikiIds }) - }, + } }, { funcName: "wikidata_label", @@ -72,32 +72,32 @@ export class WebAndCommunicationSpecialVisualisations { { name: "keyToShowWikidataFor", doc: "Use the wikidata entry from this key to show the label", - defaultValue: "wikidata", - }, + defaultValue: "wikidata" + } ], needsUrls: Wikidata.neededUrls, example: "`{wikidata_label()}` is a basic example, `{wikipedia(name:etymology:wikidata)}` to show the label itself", - constr: (_, tagsSource, args) => - new VariableUiElement( - tagsSource - .map((tags) => tags[args[0]]) - .map((wikidata) => { - wikidata = Utils.NoEmpty( - wikidata?.split(";")?.map((wd) => wd.trim()) ?? [] - )[0] - const entry = Wikidata.LoadWikidataEntry(wikidata) - return new VariableUiElement( - entry.map((e) => { - if (e === undefined || e["success"] === undefined) { - return wikidata - } - const response = e["success"] - return Translation.fromMap(response.labels) - }) - ) - }) - ), + constr: (_, tagsSource, args) => { + const id = tagsSource + .map((tags) => tags[args[0]]) + .map((wikidata) => { + const wikidataIds = Utils.NoEmpty( + wikidata?.split(";")?.map((wd) => wd.trim()) ?? [] + ) + return wikidataIds?.[0] + }) + const entry = id.bind(id => Wikidata.LoadWikidataEntry(id)) + + return new VariableUiElement( + entry.map((e) => { + if (e === undefined || e["success"] === undefined) { + return id.data + } + const response = e["success"] + return Translation.fromMap(response.labels) + })) + } }, new MapillaryLinkVis(), { @@ -108,29 +108,29 @@ export class WebAndCommunicationSpecialVisualisations { { name: "to", doc: "Who to send the email to?", - required: true, + required: true }, { name: "subject", doc: "The subject of the email", - required: true, + required: true }, { name: "body", doc: "The text in the email", - required: true, + required: true }, { name: "button_text", doc: "The text shown on the button in the UI", - required: true, - }, + required: true + } ], constr(__, tags, args) { return new SvelteUIElement(SendEmail, { args, tags }) - }, + } }, { funcName: "link", @@ -140,29 +140,29 @@ export class WebAndCommunicationSpecialVisualisations { { name: "text", doc: "Text to be shown", - required: true, + required: true }, { name: "href", doc: "The URL to link to. Note that this will be URI-encoded before ", - required: true, + required: true }, { name: "class", - doc: "CSS-classes to add to the element", + doc: "CSS-classes to add to the element" }, { name: "download", - doc: "Expects a string which denotes the filename to download the contents of `href` into. If set, this link will act as a download-button.", + doc: "Expects a string which denotes the filename to download the contents of `href` into. If set, this link will act as a download-button." }, { name: "arialabel", - doc: "If set, this text will be used as aria-label", + doc: "If set, this text will be used as aria-label" }, { name: "icon", - doc: "If set, show this icon next to the link. You might want to combine this with `class: button`", - }, + doc: "If set, show this icon next to the link. You might want to combine this with `class: button`" + } ], constr( @@ -184,10 +184,10 @@ export class WebAndCommunicationSpecialVisualisations { download: tagSource.map((tags) => Utils.SubstituteKeys(download, tags)), ariaLabel: tagSource.map((tags) => Utils.SubstituteKeys(ariaLabel, tags)), newTab: new ImmutableStore(newTab), - icon: tagSource.map((tags) => Utils.SubstituteKeys(icon, tags)), + icon: tagSource.map((tags) => Utils.SubstituteKeys(icon, tags)) }).setSpan() - }, - }, + } + } ] } }