elk/components/account/AccountPaginator.client.vue

36 lines
904 B
Vue
Raw Normal View History

<script setup lang="ts">
import type { Account, Paginator } from 'masto'
const { paginator } = defineProps<{
paginator: Paginator<any, Account[]>
}>()
2022-11-21 22:59:51 +00:00
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>
2022-11-17 07:35:42 +00:00
<CommonPaginator
:paginator="paginator"
border="t border"
2022-11-21 22:59:51 +00:00
@items="onNewItems"
2022-11-17 07:35:42 +00:00
>
<template #default="{ item }">
<AccountCard
:account="item"
2022-11-21 22:59:51 +00:00
:following="metadataMap[item.id]?.following"
2022-11-17 07:35:42 +00:00
border="b border" py-1
/>
2022-11-16 16:11:08 +00:00
</template>
</CommonPaginator>
</template>