2022-12-01 06:46:26 +00:00
|
|
|
<script setup lang="ts">
|
2023-01-08 06:21:09 +00:00
|
|
|
import type { mastodon } from 'masto'
|
2023-06-23 12:24:10 +00:00
|
|
|
import { toggleBlockAccount, toggleMuteAccount, useRelationship } from '~~/composables/masto/relationship'
|
2022-12-01 06:46:26 +00:00
|
|
|
|
|
|
|
const props = defineProps<{
|
2023-01-08 06:21:09 +00:00
|
|
|
status: mastodon.v1.Status
|
2022-12-01 06:46:26 +00:00
|
|
|
details?: boolean
|
|
|
|
command?: boolean
|
|
|
|
}>()
|
|
|
|
|
2023-04-30 15:19:14 +00:00
|
|
|
const emit = defineEmits<{
|
|
|
|
(event: 'afterEdit'): void
|
|
|
|
}>()
|
|
|
|
|
2023-08-02 10:27:31 +00:00
|
|
|
const focusEditor = inject<typeof noop>('focus-editor', noop)
|
|
|
|
|
2022-12-01 06:46:26 +00:00
|
|
|
const { details, command } = $(props)
|
|
|
|
|
|
|
|
const {
|
|
|
|
status,
|
|
|
|
isLoading,
|
|
|
|
toggleBookmark,
|
|
|
|
toggleFavourite,
|
|
|
|
togglePin,
|
|
|
|
toggleReblog,
|
2022-12-28 21:44:23 +00:00
|
|
|
toggleMute,
|
2022-12-01 06:46:26 +00:00
|
|
|
} = $(useStatusActions(props))
|
|
|
|
|
|
|
|
const clipboard = useClipboard()
|
|
|
|
const router = useRouter()
|
|
|
|
const route = useRoute()
|
2023-01-07 08:55:01 +00:00
|
|
|
const { t } = useI18n()
|
2023-01-12 17:52:52 +00:00
|
|
|
const userSettings = useUserSettings()
|
2023-05-06 15:52:33 +00:00
|
|
|
const useStarFavoriteIcon = usePreferences('useStarFavoriteIcon')
|
2022-12-01 06:46:26 +00:00
|
|
|
|
|
|
|
const isAuthor = $computed(() => status.account.id === currentUser.value?.account.id)
|
|
|
|
|
2023-01-15 08:38:02 +00:00
|
|
|
const { client } = $(useMasto())
|
2023-01-02 21:00:51 +00:00
|
|
|
|
2023-03-30 19:01:24 +00:00
|
|
|
function getPermalinkUrl(status: mastodon.v1.Status) {
|
2022-12-04 19:56:33 +00:00
|
|
|
const url = getStatusPermalinkRoute(status)
|
2022-12-01 06:46:26 +00:00
|
|
|
if (url)
|
2023-01-02 21:00:51 +00:00
|
|
|
return `${location.origin}/${url}`
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
2023-03-30 19:01:24 +00:00
|
|
|
async function copyLink(status: mastodon.v1.Status) {
|
2023-01-02 21:00:51 +00:00
|
|
|
const url = getPermalinkUrl(status)
|
|
|
|
if (url)
|
|
|
|
await clipboard.copy(url)
|
|
|
|
}
|
|
|
|
|
2023-03-30 19:01:24 +00:00
|
|
|
async function copyOriginalLink(status: mastodon.v1.Status) {
|
2023-01-19 15:18:08 +00:00
|
|
|
const url = status.url
|
|
|
|
if (url)
|
|
|
|
await clipboard.copy(url)
|
|
|
|
}
|
|
|
|
|
2023-01-02 21:00:51 +00:00
|
|
|
const { share, isSupported: isShareSupported } = useShare()
|
2023-03-30 19:01:24 +00:00
|
|
|
async function shareLink(status: mastodon.v1.Status) {
|
2023-01-02 21:00:51 +00:00
|
|
|
const url = getPermalinkUrl(status)
|
|
|
|
if (url)
|
|
|
|
await share({ url })
|
2022-12-01 06:46:26 +00:00
|
|
|
}
|
2023-01-02 21:00:51 +00:00
|
|
|
|
2023-03-30 19:01:24 +00:00
|
|
|
async function deleteStatus() {
|
2023-01-07 08:55:01 +00:00
|
|
|
if (await openConfirmDialog({
|
2023-01-16 08:56:36 +00:00
|
|
|
title: t('confirm.delete_posts.title'),
|
2024-01-09 19:51:36 +00:00
|
|
|
description: t('confirm.delete_posts.description'),
|
2023-01-16 08:56:36 +00:00
|
|
|
confirm: t('confirm.delete_posts.confirm'),
|
|
|
|
cancel: t('confirm.delete_posts.cancel'),
|
2023-01-07 08:55:01 +00:00
|
|
|
}) !== 'confirm')
|
|
|
|
return
|
2022-12-01 06:46:26 +00:00
|
|
|
|
2022-12-25 14:52:37 +00:00
|
|
|
removeCachedStatus(status.id)
|
2024-01-09 08:56:15 +00:00
|
|
|
await client.v1.statuses.$select(status.id).remove()
|
2022-12-01 06:46:26 +00:00
|
|
|
|
2022-12-25 14:52:37 +00:00
|
|
|
if (route.name === 'status')
|
2022-12-01 06:46:26 +00:00
|
|
|
router.back()
|
|
|
|
|
|
|
|
// TODO when timeline, remove this item
|
|
|
|
}
|
|
|
|
|
2023-03-30 19:01:24 +00:00
|
|
|
async function deleteAndRedraft() {
|
2023-08-02 10:41:47 +00:00
|
|
|
if (await openConfirmDialog({
|
|
|
|
title: t('confirm.delete_posts.title'),
|
2024-01-09 19:51:36 +00:00
|
|
|
description: t('confirm.delete_posts.description'),
|
2023-08-02 10:41:47 +00:00
|
|
|
confirm: t('confirm.delete_posts.confirm'),
|
|
|
|
cancel: t('confirm.delete_posts.cancel'),
|
|
|
|
}) !== 'confirm')
|
|
|
|
return
|
|
|
|
|
2022-12-01 06:46:26 +00:00
|
|
|
if (process.dev) {
|
|
|
|
// eslint-disable-next-line no-alert
|
|
|
|
const result = confirm('[DEV] Are you sure you want to delete and re-draft this post?')
|
|
|
|
if (!result)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-12-25 14:52:37 +00:00
|
|
|
removeCachedStatus(status.id)
|
2024-01-09 08:56:15 +00:00
|
|
|
await client.v1.statuses.$select(status.id).remove()
|
2023-01-01 15:57:49 +00:00
|
|
|
await openPublishDialog('dialog', await getDraftFromStatus(status), true)
|
|
|
|
|
|
|
|
// Go to the new status, if the page is the old status
|
2023-01-04 09:39:12 +00:00
|
|
|
if (lastPublishDialogStatus.value && route.name === 'status')
|
2023-01-01 15:57:49 +00:00
|
|
|
router.push(getStatusRoute(lastPublishDialogStatus.value))
|
2022-12-01 06:46:26 +00:00
|
|
|
}
|
|
|
|
|
2023-03-30 19:01:24 +00:00
|
|
|
function reply() {
|
2023-08-02 10:27:31 +00:00
|
|
|
if (!checkLogin())
|
|
|
|
return
|
2022-12-01 06:46:26 +00:00
|
|
|
if (details) {
|
2023-08-02 10:27:31 +00:00
|
|
|
focusEditor()
|
2022-12-01 06:46:26 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
const { key, draft } = getReplyDraft(status)
|
|
|
|
openPublishDialog(key, draft())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-04 22:10:10 +00:00
|
|
|
async function editStatus() {
|
2023-04-30 15:19:14 +00:00
|
|
|
await openPublishDialog(`edit-${status.id}`, {
|
2022-12-04 22:10:10 +00:00
|
|
|
...await getDraftFromStatus(status),
|
2022-12-01 06:46:26 +00:00
|
|
|
editingStatus: status,
|
2022-12-21 14:21:45 +00:00
|
|
|
}, true)
|
2023-04-30 15:19:14 +00:00
|
|
|
emit('afterEdit')
|
2022-12-01 06:46:26 +00:00
|
|
|
}
|
2023-01-08 20:08:45 +00:00
|
|
|
|
2023-03-30 19:01:24 +00:00
|
|
|
function showFavoritedAndBoostedBy() {
|
2023-01-08 20:08:45 +00:00
|
|
|
openFavoridedBoostedByDialog(status.id)
|
|
|
|
}
|
2022-12-01 06:46:26 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-01-01 14:29:11 +00:00
|
|
|
<CommonDropdown flex-none ms3 placement="bottom" :eager-mount="command">
|
2022-12-01 06:46:26 +00:00
|
|
|
<StatusActionButton
|
|
|
|
:content="$t('action.more')"
|
2023-01-12 09:40:49 +00:00
|
|
|
color="text-primary"
|
|
|
|
hover="text-primary"
|
2023-03-19 12:24:27 +00:00
|
|
|
elk-group-hover="bg-primary-light"
|
2022-12-02 07:27:44 +00:00
|
|
|
icon="i-ri:more-line"
|
|
|
|
my--2
|
2022-12-01 06:46:26 +00:00
|
|
|
/>
|
|
|
|
|
|
|
|
<template #popper>
|
|
|
|
<div flex="~ col">
|
2023-04-23 10:21:33 +00:00
|
|
|
<template v-if="getPreferences(userSettings, 'zenMode')">
|
2022-12-01 06:46:26 +00:00
|
|
|
<CommonDropdownItem
|
|
|
|
:text="$t('action.reply')"
|
2023-01-08 09:03:23 +00:00
|
|
|
icon="i-ri:chat-1-line"
|
2022-12-01 06:46:26 +00:00
|
|
|
:command="command"
|
|
|
|
@click="reply()"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<CommonDropdownItem
|
|
|
|
:text="status.reblogged ? $t('action.boosted') : $t('action.boost')"
|
|
|
|
icon="i-ri:repeat-fill"
|
|
|
|
:class="status.reblogged ? 'text-green' : ''"
|
|
|
|
:command="command"
|
|
|
|
:disabled="isLoading.reblogged"
|
|
|
|
@click="toggleReblog()"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<CommonDropdownItem
|
|
|
|
:text="status.favourited ? $t('action.favourited') : $t('action.favourite')"
|
2023-05-06 15:52:33 +00:00
|
|
|
:icon="useStarFavoriteIcon
|
|
|
|
? status.favourited ? 'i-ri:star-fill' : 'i-ri:star-line'
|
|
|
|
: status.favourited ? 'i-ri:heart-3-fill' : 'i-ri:heart-3-line'"
|
|
|
|
:class="status.favourited
|
|
|
|
? useStarFavoriteIcon ? 'text-yellow' : 'text-rose'
|
|
|
|
: ''
|
|
|
|
"
|
2022-12-01 06:46:26 +00:00
|
|
|
:command="command"
|
|
|
|
:disabled="isLoading.favourited"
|
|
|
|
@click="toggleFavourite()"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<CommonDropdownItem
|
|
|
|
:text="status.bookmarked ? $t('action.bookmarked') : $t('action.bookmark')"
|
|
|
|
:icon="status.bookmarked ? 'i-ri:bookmark-fill' : 'i-ri:bookmark-line'"
|
2023-05-06 15:52:33 +00:00
|
|
|
:class="status.bookmarked
|
|
|
|
? useStarFavoriteIcon ? 'text-rose' : 'text-yellow'
|
|
|
|
: ''
|
|
|
|
"
|
2022-12-01 06:46:26 +00:00
|
|
|
:command="command"
|
|
|
|
:disabled="isLoading.bookmarked"
|
|
|
|
@click="toggleBookmark()"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
|
2023-01-08 20:08:45 +00:00
|
|
|
<CommonDropdownItem
|
|
|
|
:text="$t('menu.show_favourited_and_boosted_by')"
|
|
|
|
icon="i-ri:hearts-line"
|
|
|
|
:command="command"
|
|
|
|
@click="showFavoritedAndBoostedBy()"
|
|
|
|
/>
|
|
|
|
|
2022-12-01 06:46:26 +00:00
|
|
|
<CommonDropdownItem
|
|
|
|
:text="$t('menu.copy_link_to_post')"
|
|
|
|
icon="i-ri:link"
|
|
|
|
:command="command"
|
|
|
|
@click="copyLink(status)"
|
|
|
|
/>
|
|
|
|
|
2023-01-19 15:18:08 +00:00
|
|
|
<CommonDropdownItem
|
|
|
|
:text="$t('menu.copy_original_link_to_post')"
|
|
|
|
icon="i-ri:links-fill"
|
|
|
|
:command="command"
|
|
|
|
@click="copyOriginalLink(status)"
|
|
|
|
/>
|
|
|
|
|
2023-01-02 21:00:51 +00:00
|
|
|
<CommonDropdownItem
|
|
|
|
v-if="isShareSupported"
|
|
|
|
:text="$t('menu.share_post')"
|
|
|
|
icon="i-ri:share-line"
|
|
|
|
:command="command"
|
|
|
|
@click="shareLink(status)"
|
|
|
|
/>
|
|
|
|
|
2022-12-28 21:44:23 +00:00
|
|
|
<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')"
|
|
|
|
:icon="status.muted ? 'i-ri:eye-line' : 'i-ri:eye-off-line'"
|
|
|
|
:command="command"
|
|
|
|
:disabled="isLoading.muted"
|
|
|
|
@click="toggleMute()"
|
|
|
|
/>
|
|
|
|
|
2023-01-05 16:48:20 +00:00
|
|
|
<NuxtLink v-if="status.url" :to="status.url" external target="_blank">
|
2022-12-01 06:46:26 +00:00
|
|
|
<CommonDropdownItem
|
|
|
|
:text="$t('menu.open_in_original_site')"
|
|
|
|
icon="i-ri:arrow-right-up-line"
|
|
|
|
:command="command"
|
|
|
|
/>
|
|
|
|
</NuxtLink>
|
|
|
|
|
2023-01-15 08:38:02 +00:00
|
|
|
<template v-if="isHydrated && currentUser">
|
2022-12-01 06:46:26 +00:00
|
|
|
<template v-if="isAuthor">
|
|
|
|
<CommonDropdownItem
|
|
|
|
:text="status.pinned ? $t('menu.unpin_on_profile') : $t('menu.pin_on_profile')"
|
|
|
|
icon="i-ri:pushpin-line"
|
|
|
|
:command="command"
|
|
|
|
@click="togglePin"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<CommonDropdownItem
|
|
|
|
:text="$t('menu.edit')"
|
|
|
|
icon="i-ri:edit-line"
|
|
|
|
:command="command"
|
|
|
|
@click="editStatus"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<CommonDropdownItem
|
|
|
|
:text="$t('menu.delete')"
|
|
|
|
icon="i-ri:delete-bin-line"
|
|
|
|
text-red-600
|
|
|
|
:command="command"
|
|
|
|
@click="deleteStatus"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<CommonDropdownItem
|
|
|
|
:text="$t('menu.delete_and_redraft')"
|
|
|
|
icon="i-ri:eraser-line"
|
|
|
|
text-red-600
|
|
|
|
:command="command"
|
|
|
|
@click="deleteAndRedraft"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<CommonDropdownItem
|
|
|
|
:text="$t('menu.mention_account', [`@${status.account.acct}`])"
|
|
|
|
icon="i-ri:at-line"
|
|
|
|
:command="command"
|
|
|
|
@click="mentionUser(status.account)"
|
|
|
|
/>
|
2023-06-23 12:24:10 +00:00
|
|
|
|
|
|
|
<CommonDropdownItem
|
|
|
|
v-if="!useRelationship(status.account).value?.muting"
|
|
|
|
:text="$t('menu.mute_account', [`@${status.account.acct}`])"
|
|
|
|
icon="i-ri:volume-mute-line"
|
|
|
|
:command="command"
|
|
|
|
@click="toggleMuteAccount(useRelationship(status.account).value!, status.account)"
|
|
|
|
/>
|
|
|
|
<CommonDropdownItem
|
|
|
|
v-else
|
|
|
|
:text="$t('menu.unmute_account', [`@${status.account.acct}`])"
|
|
|
|
icon="i-ri:volume-up-fill"
|
|
|
|
:command="command"
|
|
|
|
@click="toggleMuteAccount(useRelationship(status.account).value!, status.account)"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<CommonDropdownItem
|
|
|
|
v-if="!useRelationship(status.account).value?.blocking"
|
|
|
|
:text="$t('menu.block_account', [`@${status.account.acct}`])"
|
|
|
|
icon="i-ri:forbid-2-line"
|
|
|
|
:command="command"
|
|
|
|
@click="toggleBlockAccount(useRelationship(status.account).value!, status.account)"
|
|
|
|
/>
|
|
|
|
<CommonDropdownItem
|
|
|
|
v-else
|
|
|
|
:text="$t('menu.unblock_account', [`@${status.account.acct}`])"
|
|
|
|
icon="i-ri:checkbox-circle-line"
|
|
|
|
:command="command"
|
|
|
|
@click="toggleBlockAccount(useRelationship(status.account).value!, status.account)"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<template v-if="getServerName(status.account) && getServerName(status.account) !== currentServer">
|
|
|
|
<CommonDropdownItem
|
|
|
|
v-if="!useRelationship(status.account).value?.domainBlocking"
|
|
|
|
:text="$t('menu.block_domain', [getServerName(status.account)])"
|
|
|
|
icon="i-ri:shut-down-line"
|
|
|
|
:command="command"
|
|
|
|
@click="toggleBlockDomain(useRelationship(status.account).value!, status.account)"
|
|
|
|
/>
|
|
|
|
<CommonDropdownItem
|
|
|
|
v-else
|
|
|
|
:text="$t('menu.unblock_domain', [getServerName(status.account)])"
|
|
|
|
icon="i-ri:restart-line"
|
|
|
|
:command="command"
|
|
|
|
@click="toggleBlockDomain(useRelationship(status.account).value!, status.account)"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<CommonDropdownItem
|
|
|
|
:text="$t('menu.report_account', [`@${status.account.acct}`])"
|
|
|
|
icon="i-ri:flag-2-line"
|
|
|
|
:command="command"
|
|
|
|
@click="openReportDialog(status.account, status)"
|
|
|
|
/>
|
2022-12-01 06:46:26 +00:00
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</CommonDropdown>
|
|
|
|
</template>
|