From eb1f769e32cfee1c84535c0ff2da19c5f99db189 Mon Sep 17 00:00:00 2001 From: webfansplz <308241863@qq.com> Date: Sun, 15 Jan 2023 16:33:55 +0800 Subject: [PATCH] feat: add confirm for account handle (#1126) --- components/account/AccountMoreButton.vue | 42 +++++++++++++++--------- locales/en-US.json | 2 +- locales/zh-CN.json | 2 +- locales/zh-TW.json | 2 +- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/components/account/AccountMoreButton.vue b/components/account/AccountMoreButton.vue index 7cf084db..70c99b1a 100644 --- a/components/account/AccountMoreButton.vue +++ b/components/account/AccountMoreButton.vue @@ -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}`]))" /> { :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}`]))" /> { :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}`]))" /> diff --git a/locales/en-US.json b/locales/en-US.json index 32001497..d3dff318 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -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", diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 5f6cb3d5..9f69ca8c 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -88,7 +88,7 @@ "confirm_dialog": { "cancel": "否", "confirm": "是", - "title": "你确定吗?" + "title": "你确定 {0} 吗?" }, "end_of_list": "列表到底啦", "error": "错误", diff --git a/locales/zh-TW.json b/locales/zh-TW.json index da046b8e..3b44351d 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -91,7 +91,7 @@ "confirm_dialog": { "cancel": "否", "confirm": "是", - "title": "你確定嗎?" + "title": "你確定 {0} 嗎?" }, "end_of_list": "清單到底啦", "error": "錯誤",