From ddb6e90e215f33d3f92c6c79068fefcaa384d6e1 Mon Sep 17 00:00:00 2001 From: Ivan Demchuk Date: Mon, 2 Jan 2023 23:00:51 +0200 Subject: [PATCH] feat: browser native post share (#714) --- components/status/StatusActionsMore.vue | 28 +++++++++++++++++++++++-- locales/en-GB.json | 1 + locales/en-US.json | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/components/status/StatusActionsMore.vue b/components/status/StatusActionsMore.vue index 8f66141d..bb3cf503 100644 --- a/components/status/StatusActionsMore.vue +++ b/components/status/StatusActionsMore.vue @@ -38,11 +38,27 @@ const toggleTranslation = async () => { } const masto = useMasto() -const copyLink = async (status: Status) => { + +const getPermalinkUrl = (status: Status) => { const url = getStatusPermalinkRoute(status) if (url) - await clipboard.copy(`${location.origin}/${url}`) + return `${location.origin}/${url}` + return null } + +const copyLink = async (status: Status) => { + const url = getPermalinkUrl(status) + if (url) + await clipboard.copy(url) +} + +const { share, isSupported: isShareSupported } = useShare() +const shareLink = async (status: Status) => { + const url = getPermalinkUrl(status) + if (url) + await share({ url }) +} + const deleteStatus = async () => { // TODO confirm to delete if (process.dev) { @@ -153,6 +169,14 @@ async function editStatus() { @click="copyLink(status)" /> + +