Skip to content

Commit

Permalink
feat: browser native post share (#714)
Browse files Browse the repository at this point in the history
  • Loading branch information
Demivan authored Jan 2, 2023
1 parent 296a7b6 commit ddb6e90
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
28 changes: 26 additions & 2 deletions components/status/StatusActionsMore.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -153,6 +169,14 @@ async function editStatus() {
@click="copyLink(status)"
/>

<CommonDropdownItem
v-if="isShareSupported"
:text="$t('menu.share_post')"
icon="i-ri:share-line"
:command="command"
@click="shareLink(status)"
/>

<CommonDropdownItem
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')"
Expand Down
1 change: 1 addition & 0 deletions locales/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"mute_conversation": "Mute this post",
"open_in_original_site": "Open in original site",
"pin_on_profile": "Pin on profile",
"share_post": "Share this post",
"show_untranslated": "Show untranslated",
"toggle_theme": {
"dark": "Toggle dark mode",
Expand Down
1 change: 1 addition & 0 deletions locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"mute_conversation": "Mute this post",
"open_in_original_site": "Open in original site",
"pin_on_profile": "Pin on profile",
"share_post": "Share this post",
"show_untranslated": "Show untranslated",
"toggle_theme": {
"dark": "Toggle dark mode",
Expand Down

0 comments on commit ddb6e90

Please sign in to comment.