Fix share button

This commit is contained in:
Pieter Vander Vennet 2020-11-23 12:54:10 +01:00
parent 02ce4e5d7e
commit 4d2e8b6f24
4 changed files with 14 additions and 17 deletions

View file

@ -85,11 +85,6 @@ export class InitUiElements {
throw "Incorrect layout" 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); console.log("Using layout: ", layoutToUse.id, "LayoutFromBase64 is ", layoutFromBase64);
State.state = new State(layoutToUse); State.state = new State(layoutToUse);

View file

@ -23,7 +23,7 @@ export default class State {
// The singleton of the global state // The singleton of the global state
public static state: 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 // The user journey states thresholds when a new feature gets unlocked
public static userJourney = { public static userJourney = {

View file

@ -12,9 +12,6 @@ export default class ShareButton extends UIElement{
super(); super();
this._embedded = embedded; this._embedded = embedded;
this._shareData = shareData; this._shareData = shareData;
if(this._shareData.url.indexOf("#")> 0){
this._shareData.url = this._shareData.url.replace("#","&hash_content=");
}
} }
InnerRender(): string { InnerRender(): string {
@ -25,6 +22,7 @@ export default class ShareButton extends UIElement{
super.InnerUpdate(htmlElement); super.InnerUpdate(htmlElement);
const self= this; const self= this;
htmlElement.addEventListener('click', () => { htmlElement.addEventListener('click', () => {
alert("URL:" + self._shareData.url)
if (navigator.share) { if (navigator.share) {
navigator.share(self._shareData).then(() => { navigator.share(self._shareData).then(() => {
console.log('Thanks for sharing!'); console.log('Thanks for sharing!');

View file

@ -197,17 +197,21 @@ export default class SpecialVisualizations {
} }
], ],
constr: (tagSource: UIEventSource<any>, args) => { constr: (tagSource: UIEventSource<any>, args) => {
if (window.navigator.share) { if (window.navigator.share || true) {
const title = State.state.layoutToUse.data.title.txt; const title = State.state.layoutToUse.data.title.txt;
let name = tagSource.data.name; let name = tagSource.data.name;
if(name){ if (name) {
name = `${name} (${title})` name = `${name} (${title})`
}else{ } else {
name = title; name = title;
} }
let url = args[0] ?? ""
if (url === "") {
url = window.location.href
}
return new ShareButton(Svg.share_svg(), { return new ShareButton(Svg.share_svg(), {
title: name, title: name,
url: args[0] ?? window.location.href, url: url,
text: State.state.layoutToUse.data.shortDescription.txt text: State.state.layoutToUse.data.shortDescription.txt
}) })
} else { } else {