feat: following (#22)

This commit is contained in:
patak 2022-11-21 23:59:51 +01:00 committed by GitHub
parent f97920d9d2
commit 9aa7243d43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 5 deletions

View file

@ -4,16 +4,30 @@ import type { Account, Paginator } from 'masto'
const { paginator } = defineProps<{
paginator: Paginator<any, Account[]>
}>()
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
}
</script>
<template>
<CommonPaginator
:paginator="paginator"
border="t border"
@items="onNewItems"
>
<template #default="{ item }">
<AccountCard
:account="item"
:following="metadataMap[item.id]?.following"
border="b border" py-1
/>
</template>