feat: browser native post share (#714)

This commit is contained in:
Ivan Demchuk 2023-01-02 23:00:51 +02:00 committed by GitHub
parent 296a7b6eae
commit ddb6e90e21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 2 deletions

View file

@ -38,11 +38,27 @@ const toggleTranslation = async () => {
} }
const masto = useMasto() const masto = useMasto()
const copyLink = async (status: Status) => {
const getPermalinkUrl = (status: Status) => {
const url = getStatusPermalinkRoute(status) const url = getStatusPermalinkRoute(status)
if (url) 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 () => { const deleteStatus = async () => {
// TODO confirm to delete // TODO confirm to delete
if (process.dev) { if (process.dev) {
@ -153,6 +169,14 @@ async function editStatus() {
@click="copyLink(status)" @click="copyLink(status)"
/> />
<CommonDropdownItem
v-if="isShareSupported"
:text="$t('menu.share_post')"
icon="i-ri:share-line"
:command="command"
@click="shareLink(status)"
/>
<CommonDropdownItem <CommonDropdownItem
v-if="currentUser && (status.account.id === currentUser.account.id || status.mentions.some(m => m.id === currentUser!.account.id))" v-if="currentUser && (status.account.id === currentUser.account.id || status.mentions.some(m => m.id === currentUser!.account.id))"
:text="status.muted ? $t('menu.unmute_conversation') : $t('menu.mute_conversation')" :text="status.muted ? $t('menu.unmute_conversation') : $t('menu.mute_conversation')"

View file

@ -119,6 +119,7 @@
"mute_conversation": "Mute this post", "mute_conversation": "Mute this post",
"open_in_original_site": "Open in original site", "open_in_original_site": "Open in original site",
"pin_on_profile": "Pin on profile", "pin_on_profile": "Pin on profile",
"share_post": "Share this post",
"show_untranslated": "Show untranslated", "show_untranslated": "Show untranslated",
"toggle_theme": { "toggle_theme": {
"dark": "Toggle dark mode", "dark": "Toggle dark mode",

View file

@ -122,6 +122,7 @@
"mute_conversation": "Mute this post", "mute_conversation": "Mute this post",
"open_in_original_site": "Open in original site", "open_in_original_site": "Open in original site",
"pin_on_profile": "Pin on profile", "pin_on_profile": "Pin on profile",
"share_post": "Share this post",
"show_untranslated": "Show untranslated", "show_untranslated": "Show untranslated",
"toggle_theme": { "toggle_theme": {
"dark": "Toggle dark mode", "dark": "Toggle dark mode",