feat: confirm before unfollow (#1208)

Closes https://github.com/elk-zone/elk/issues/35
This commit is contained in:
webfansplz 2023-01-16 14:36:28 +08:00 committed by GitHub
parent 46d350f442
commit 512d0901ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 2 deletions

View file

@ -8,12 +8,21 @@ const { account, command, context, ...props } = defineProps<{
command?: boolean
}>()
const { t } = useI18n()
const isSelf = $(useSelfAccount(() => account))
const enable = $computed(() => !isSelf && currentUser.value)
const relationship = $computed(() => props.relationship || useRelationship(account).value)
const { client } = $(useMasto())
async function toggleFollow() {
if (relationship!.following) {
if (await openConfirmDialog({
title: t('confirm.unfollow.title'),
confirm: t('confirm.unfollow.confirm'),
cancel: t('confirm.unfollow.cancel'),
}) !== 'confirm')
return
}
relationship!.following = !relationship!.following
try {
const newRel = await client.v1.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
@ -52,8 +61,6 @@ async function unmute() {
}
}
const { t } = useI18n()
useCommand({
scope: 'Actions',
order: -2,