feat: add confirm for account handle (#1126)
This commit is contained in:
parent
274e182bdf
commit
eb1f769e32
|
@ -9,9 +9,16 @@ let relationship = $(useRelationship(account))
|
|||
|
||||
const isSelf = $(useSelfAccount(() => account))
|
||||
|
||||
const { t } = useI18n()
|
||||
const masto = useMasto()
|
||||
const toggleMute = async () => {
|
||||
// TODO: Add confirmation
|
||||
|
||||
const isConfirmed = async (title: string) => {
|
||||
return await openConfirmDialog(t('common.confirm_dialog.title', [title])) === 'confirm'
|
||||
}
|
||||
|
||||
const toggleMute = async (title: string) => {
|
||||
if (!await isConfirmed(title))
|
||||
return
|
||||
|
||||
relationship!.muting = !relationship!.muting
|
||||
relationship = relationship!.muting
|
||||
|
@ -21,22 +28,25 @@ const toggleMute = async () => {
|
|||
: await masto.v1.accounts.unmute(account.id)
|
||||
}
|
||||
|
||||
const toggleBlockUser = async () => {
|
||||
// TODO: Add confirmation
|
||||
const toggleBlockUser = async (title: string) => {
|
||||
if (!await isConfirmed(title))
|
||||
return
|
||||
|
||||
relationship!.blocking = !relationship!.blocking
|
||||
relationship = await masto.v1.accounts[relationship!.blocking ? 'block' : 'unblock'](account.id)
|
||||
}
|
||||
|
||||
const toggleBlockDomain = async () => {
|
||||
// TODO: Add confirmation
|
||||
const toggleBlockDomain = async (title: string) => {
|
||||
if (!await isConfirmed(title))
|
||||
return
|
||||
|
||||
relationship!.domainBlocking = !relationship!.domainBlocking
|
||||
await masto.v1.domainBlocks[relationship!.domainBlocking ? 'block' : 'unblock'](getServerName(account))
|
||||
}
|
||||
|
||||
const toggleReblogs = async () => {
|
||||
// TODO: Add confirmation
|
||||
const toggleReblogs = async (title: string) => {
|
||||
if (!await isConfirmed(title))
|
||||
return
|
||||
|
||||
const showingReblogs = !relationship?.showingReblogs
|
||||
relationship = await masto.v1.accounts.follow(account.id, { reblogs: showingReblogs })
|
||||
|
@ -80,14 +90,14 @@ const toggleReblogs = async () => {
|
|||
icon="i-ri:repeat-line"
|
||||
:text="$t('menu.show_reblogs', [`@${account.acct}`])"
|
||||
:command="command"
|
||||
@click="toggleReblogs"
|
||||
@click="toggleReblogs($t('menu.show_reblogs', [`@${account.acct}`]))"
|
||||
/>
|
||||
<CommonDropdownItem
|
||||
v-else
|
||||
:text="$t('menu.hide_reblogs', [`@${account.acct}`])"
|
||||
icon="i-ri:repeat-line"
|
||||
:command="command"
|
||||
@click="toggleReblogs"
|
||||
@click="toggleReblogs($t('menu.hide_reblogs', [`@${account.acct}`]))"
|
||||
/>
|
||||
|
||||
<CommonDropdownItem
|
||||
|
@ -95,14 +105,14 @@ const toggleReblogs = async () => {
|
|||
:text="$t('menu.mute_account', [`@${account.acct}`])"
|
||||
icon="i-ri:volume-up-fill"
|
||||
:command="command"
|
||||
@click="toggleMute"
|
||||
@click="toggleMute($t('menu.mute_account', [`@${account.acct}`]))"
|
||||
/>
|
||||
<CommonDropdownItem
|
||||
v-else
|
||||
:text="$t('menu.unmute_account', [`@${account.acct}`])"
|
||||
icon="i-ri:volume-mute-line"
|
||||
:command="command"
|
||||
@click="toggleMute"
|
||||
@click="toggleMute($t('menu.unmute_account', [`@${account.acct}`]))"
|
||||
/>
|
||||
|
||||
<CommonDropdownItem
|
||||
|
@ -110,14 +120,14 @@ const toggleReblogs = async () => {
|
|||
:text="$t('menu.block_account', [`@${account.acct}`])"
|
||||
icon="i-ri:forbid-2-line"
|
||||
:command="command"
|
||||
@click="toggleBlockUser"
|
||||
@click="toggleBlockUser($t('menu.block_account', [`@${account.acct}`]))"
|
||||
/>
|
||||
<CommonDropdownItem
|
||||
v-else
|
||||
:text="$t('menu.unblock_account', [`@${account.acct}`])"
|
||||
icon="i-ri:checkbox-circle-line"
|
||||
:command="command"
|
||||
@click="toggleBlockUser"
|
||||
@click="toggleBlockUser($t('menu.unblock_account', [`@${account.acct}`]))"
|
||||
/>
|
||||
|
||||
<template v-if="getServerName(account) !== currentServer">
|
||||
|
@ -126,14 +136,14 @@ const toggleReblogs = async () => {
|
|||
:text="$t('menu.block_domain', [getServerName(account)])"
|
||||
icon="i-ri:shut-down-line"
|
||||
:command="command"
|
||||
@click="toggleBlockDomain"
|
||||
@click="toggleBlockDomain($t('menu.block_domain', [getServerName(account)]))"
|
||||
/>
|
||||
<CommonDropdownItem
|
||||
v-else
|
||||
:text="$t('menu.unblock_domain', [getServerName(account)])"
|
||||
icon="i-ri:restart-line"
|
||||
:command="command"
|
||||
@click="toggleBlockDomain"
|
||||
@click="toggleBlockDomain($t('menu.unblock_domain', [getServerName(account)]))"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
"confirm_dialog": {
|
||||
"cancel": "No",
|
||||
"confirm": "Yes",
|
||||
"title": "Are you sure?"
|
||||
"title": "Are you sure {0}?"
|
||||
},
|
||||
"end_of_list": "End of the list",
|
||||
"error": "ERROR",
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
"confirm_dialog": {
|
||||
"cancel": "否",
|
||||
"confirm": "是",
|
||||
"title": "你确定吗?"
|
||||
"title": "你确定 {0} 吗?"
|
||||
},
|
||||
"end_of_list": "列表到底啦",
|
||||
"error": "错误",
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
"confirm_dialog": {
|
||||
"cancel": "否",
|
||||
"confirm": "是",
|
||||
"title": "你確定嗎?"
|
||||
"title": "你確定 {0} 嗎?"
|
||||
},
|
||||
"end_of_list": "清單到底啦",
|
||||
"error": "錯誤",
|
||||
|
|
Loading…
Reference in a new issue