From 9aa7243d43a681408030dbee7fa57681afd2c6fd Mon Sep 17 00:00:00 2001 From: patak Date: Mon, 21 Nov 2022 23:59:51 +0100 Subject: [PATCH] feat: following (#22) --- components/account/AccountCard.vue | 23 ++++++++++++++++--- .../account/AccountPaginator.client.vue | 14 +++++++++++ components/common/CommonPaginator.vue | 9 +++++++- composables/paginator.ts | 5 +++- 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/components/account/AccountCard.vue b/components/account/AccountCard.vue index 199d587a..5fa3c9c6 100644 --- a/components/account/AccountCard.vue +++ b/components/account/AccountCard.vue @@ -1,9 +1,26 @@ diff --git a/components/account/AccountPaginator.client.vue b/components/account/AccountPaginator.client.vue index 0e75d1d5..14389294 100644 --- a/components/account/AccountPaginator.client.vue +++ b/components/account/AccountPaginator.client.vue @@ -4,16 +4,30 @@ import type { Account, Paginator } from 'masto' const { paginator } = defineProps<{ paginator: Paginator }>() + +const masto = await useMasto() + +const metadataMap = $ref<{ [key: string]: { following?: boolean } }>({}) +async function onNewItems(items: Account[]) { + for (const item of items) + metadataMap[item.id] = { following: undefined } + + const relationships = await masto.accounts.fetchRelationships(items.map(item => item.id)) + for (const rel of relationships) + metadataMap[rel.id].following = rel.following +}