fix WebShare API permissions by checking the URL to share

This commit is contained in:
survellow
2024-09-23 19:03:24 +02:00
parent f40ec4fc36
commit 3ed25a412f
2 changed files with 17 additions and 13 deletions

View File

@ -84,14 +84,16 @@ const forwardToHTWKalendar = () => {
});
};
const shareLink = () => {
if (typeof navigator.share === 'function' && navigator.canShare()) {
navigator
.share({
const shareData = computed(() => ({
title: t("calendarLink.shareTitle"),
text: t("calendarLink.shareText") + getLink(),
url: "https://" + domain + "/",
})
}));
const shareLink = () => {
if (typeof navigator.share === 'function' && navigator.canShare(shareData.value)) {
navigator
.share(shareData.value)
.then(() => {
toast.add({
severity: "info",
@ -142,7 +144,7 @@ const actions = computed(() => {
}
];
if (typeof navigator.share === 'function' && navigator.canShare()) {
if (typeof navigator.share === 'function' && navigator.canShare(shareData.value)) {
actionList.push({
label: t("calendarLink.share"),
icon: "pi pi-share-alt",

View File

@ -59,12 +59,14 @@ function shareLink() {
}
const link = "https://" + window.location.hostname + "/calendar/view?token=" + token.value + datePart;
if (typeof navigator.share === "function" && navigator.canShare()) {
navigator.share({
const shareData = {
title: t("calendarLink.shareLinkTitle"),
text: t("calendarLink.shareLinkText"),
url: link,
});
};
if (typeof navigator.share === "function" && navigator.canShare(shareData)) {
navigator.share(shareData);
} else {
navigator.clipboard.writeText(link).then(() => {
toast.add({