From 84478984dc508bca2d747bed7df0787e87686133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Sat, 26 Nov 2022 20:58:10 +0800 Subject: [PATCH] feat: support more actions for user --- components/account/AccountFollowButton.vue | 10 ++- components/account/AccountMoreButton.vue | 78 +++++++++++++++------ components/common/dropdown/DropdownItem.vue | 2 + components/main/MainContent.vue | 19 +++-- pages/@[account]/[status].vue | 2 +- pages/@[account]/index.vue | 6 +- pages/blocks.vue | 20 ++++++ pages/domain_blocks.vue | 34 +++++++++ pages/mutes.vue | 20 ++++++ pages/pinned.vue | 22 ++++++ pages/public/index.vue | 6 +- pages/tags/[tag].vue | 2 +- 12 files changed, 184 insertions(+), 37 deletions(-) create mode 100644 pages/blocks.vue create mode 100644 pages/domain_blocks.vue create mode 100644 pages/mutes.vue create mode 100644 pages/pinned.vue diff --git a/components/account/AccountFollowButton.vue b/components/account/AccountFollowButton.vue index 13b020c2..bc4e496a 100644 --- a/components/account/AccountFollowButton.vue +++ b/components/account/AccountFollowButton.vue @@ -6,11 +6,17 @@ const { account } = defineProps<{ }>() const isSelf = $computed(() => currentUser.value?.account.id === account.id) -const relationship = $(useRelationship(account)) +let relationship = $(useRelationship(account)) async function toggleFollow() { relationship!.following = !relationship!.following - await masto.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id) + try { + relationship = await masto.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id) + } + catch { + // TODO error handling + relationship!.following = !relationship!.following + } } diff --git a/components/account/AccountMoreButton.vue b/components/account/AccountMoreButton.vue index 5bda60c4..62590c8f 100644 --- a/components/account/AccountMoreButton.vue +++ b/components/account/AccountMoreButton.vue @@ -8,34 +8,29 @@ let relationship = $(useRelationship(account)) const isSelf = $computed(() => currentUser.value?.account.id === account.id) -const mute = async () => { +const toggleMute = async () => { // TODO: Add confirmation - relationship!.muting = true - relationship = await masto.accounts.mute(account.id, { - // TODO support more options - }) + relationship!.muting = !relationship!.muting + relationship = relationship!.muting + ? await masto.accounts.mute(account.id, { + // TODO support more options + }) + : await masto.accounts.unmute(account.id) } -const unmute = async () => { +const toggleBlockUser = async () => { // TODO: Add confirmation - relationship!.muting = false - relationship = await masto.accounts.unmute(account.id) + relationship!.blocking = !relationship!.blocking + relationship = await masto.accounts[relationship!.blocking ? 'block' : 'unblock'](account.id) } -const block = async () => { +const toggleBlockDomain = async () => { // TODO: Add confirmation - relationship!.blocking = true - relationship = await masto.accounts.block(account.id) -} - -const unblock = async () => { - // TODO: Add confirmation - - relationship!.blocking = false - relationship = await masto.accounts.unblock(account.id) + relationship!.domainBlocking = !relationship!.domainBlocking + await masto.domainBlocks[relationship!.domainBlocking ? 'block' : 'unblock'](getServerName(account)) } @@ -62,19 +57,58 @@ const unblock = async () => { Direct message @{{ account.acct }} - + Mute @{{ account.acct }} - + Unmute @{{ account.acct }} - + Block @{{ account.acct }} - + Unblock @{{ account.acct }} + + + Block domain {{ getServerName(account) }} + + + Unblock domain {{ getServerName(account) }} + + + + diff --git a/components/common/dropdown/DropdownItem.vue b/components/common/dropdown/DropdownItem.vue index 7dc93b7e..6fcd81c2 100644 --- a/components/common/dropdown/DropdownItem.vue +++ b/components/common/dropdown/DropdownItem.vue @@ -19,6 +19,7 @@ const handleClick = (evt: MouseEvent) => { diff --git a/components/main/MainContent.vue b/components/main/MainContent.vue index c164f2ee..1b3de65e 100644 --- a/components/main/MainContent.vue +++ b/components/main/MainContent.vue @@ -1,3 +1,9 @@ + +