From 4d2e8b6f24a23f8e173eaf2bcfc8308215103fd5 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Mon, 23 Nov 2020 12:54:10 +0100 Subject: [PATCH] Fix share button --- InitUiElements.ts | 5 ----- State.ts | 2 +- UI/ShareButton.ts | 4 +--- UI/SpecialVisualizations.ts | 20 ++++++++++++-------- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/InitUiElements.ts b/InitUiElements.ts index 711e1a6c7..6af20b870 100644 --- a/InitUiElements.ts +++ b/InitUiElements.ts @@ -85,11 +85,6 @@ export class InitUiElements { throw "Incorrect layout" } - const hashContent = QueryParameters.GetQueryParameter("hash_content", "", "A workaround for the share-api which doesn't share the hash..."); - if((hashContent.data ?? "") !== ""){ - window.location.hash = hashContent.data; - } - console.log("Using layout: ", layoutToUse.id, "LayoutFromBase64 is ", layoutFromBase64); State.state = new State(layoutToUse); diff --git a/State.ts b/State.ts index 235227ac1..3cb90606e 100644 --- a/State.ts +++ b/State.ts @@ -23,7 +23,7 @@ export default class State { // The singleton of the global state public static state: State; - public static vNumber = "0.2.2a"; + public static vNumber = "0.2.2c"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = { diff --git a/UI/ShareButton.ts b/UI/ShareButton.ts index a94c55da0..a97327d8f 100644 --- a/UI/ShareButton.ts +++ b/UI/ShareButton.ts @@ -12,9 +12,6 @@ export default class ShareButton extends UIElement{ super(); this._embedded = embedded; this._shareData = shareData; - if(this._shareData.url.indexOf("#")> 0){ - this._shareData.url = this._shareData.url.replace("#","&hash_content="); - } } InnerRender(): string { @@ -25,6 +22,7 @@ export default class ShareButton extends UIElement{ super.InnerUpdate(htmlElement); const self= this; htmlElement.addEventListener('click', () => { + alert("URL:" + self._shareData.url) if (navigator.share) { navigator.share(self._shareData).then(() => { console.log('Thanks for sharing!'); diff --git a/UI/SpecialVisualizations.ts b/UI/SpecialVisualizations.ts index 0afad7be6..4e4cfc173 100644 --- a/UI/SpecialVisualizations.ts +++ b/UI/SpecialVisualizations.ts @@ -197,19 +197,23 @@ export default class SpecialVisualizations { } ], constr: (tagSource: UIEventSource, args) => { - if (window.navigator.share) { + if (window.navigator.share || true) { const title = State.state.layoutToUse.data.title.txt; let name = tagSource.data.name; - if(name){ + if (name) { name = `${name} (${title})` - }else{ + } else { name = title; } - return new ShareButton(Svg.share_svg(), { - title: name, - url: args[0] ?? window.location.href, - text: State.state.layoutToUse.data.shortDescription.txt - }) + let url = args[0] ?? "" + if (url === "") { + url = window.location.href + } + return new ShareButton(Svg.share_svg(), { + title: name, + url: url, + text: State.state.layoutToUse.data.shortDescription.txt + }) } else { return new FixedUiElement("") }