forked from Mirrors/elk
feat: browser native post share (#714)
This commit is contained in:
parent
296a7b6eae
commit
ddb6e90e21
3 changed files with 28 additions and 2 deletions
|
@ -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')"
|
||||||
|
|
|
@ -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",
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Loading…
Reference in a new issue