From ac156034d154ed99b6a975bc702abf14f120fa81 Mon Sep 17 00:00:00 2001 From: patak Date: Tue, 22 Nov 2022 14:03:36 +0100 Subject: [PATCH] feat: global relationships batching (#24) --- components/account/AccountCard.vue | 16 ++++----- components/account/AccountHeader.vue | 18 +++------- .../account/AccountPaginator.client.vue | 14 -------- components/common/CommonPaginator.vue | 9 +---- composables/masto.ts | 36 ++++++++++++++++++- 5 files changed, 47 insertions(+), 46 deletions(-) diff --git a/components/account/AccountCard.vue b/components/account/AccountCard.vue index f3d2e54c..64995ecf 100644 --- a/components/account/AccountCard.vue +++ b/components/account/AccountCard.vue @@ -1,25 +1,21 @@ @@ -27,8 +23,8 @@ function follow() {
-
-
+
+
diff --git a/components/account/AccountHeader.vue b/components/account/AccountHeader.vue index 9263c86e..bd0732ad 100644 --- a/components/account/AccountHeader.vue +++ b/components/account/AccountHeader.vue @@ -5,22 +5,14 @@ const { account } = defineProps<{ account: Account }>() -let isFollowing = $ref() -let isFollowedBy = $ref() +const relationship = $(useRelationship(account)) let masto: MastoClient -onMounted(async () => { - masto ??= await useMasto() - const relationship = (await masto.accounts.fetchRelationships([account.id]))[0] - isFollowing = relationship.following - isFollowedBy = relationship.followedBy -}) - async function toggleFollow() { - isFollowing = !isFollowing + relationship!.following = !relationship!.following masto ??= await useMasto() - await masto.accounts[isFollowing ? 'follow' : 'unfollow'](account.id) + await masto.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id) } const createdAt = $computed(() => { @@ -50,9 +42,9 @@ const createdAt = $computed(() => {
-