1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-04 16:09:59 +00:00

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,

View file

@ -104,6 +104,13 @@
"draft_title": "Draft {0}",
"drafts": "Drafts ({v})"
},
"confirm": {
"unfollow": {
"cancel": "Cancel",
"confirm": "Unfollow",
"title": "Are you sure you want to unfollow?"
}
},
"conversation": {
"with": "with"
},

View file

@ -100,6 +100,13 @@
"draft_title": "草稿 {0}",
"drafts": "草稿 ({v})"
},
"confirm": {
"unfollow": {
"cancel": "取消",
"confirm": "取消关注",
"title": "你确定要取消关注吗?"
}
},
"conversation": {
"with": "与"
},

View file

@ -103,6 +103,13 @@
"draft_title": "草稿 {0}",
"drafts": "草稿 ({v})"
},
"confirm": {
"unfollow": {
"cancel": "取消",
"confirm": "取消關注",
"title": "你確定要取消關注嗎?"
}
},
"conversation": {
"with": "與"
},