feat: global relationships batching (#24)
This commit is contained in:
parent
5dc79df091
commit
ac156034d1
5 changed files with 47 additions and 46 deletions
|
@ -4,30 +4,16 @@ 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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue