import type { CardDefinition } from '../types'; import type { Did } from '@atcute/lexicons'; import { getBlentoOrBskyProfile } from '$lib/atproto/methods'; import FriendsCard from './FriendsCard.svelte'; import FriendsCardSettings from './FriendsCardSettings.svelte'; export type FriendsProfile = Awaited>; export const FriendsCardDefinition = { type: 'friends', contentComponent: FriendsCard, settingsComponent: FriendsCardSettings, createNew: (card) => { card.w = 4; card.h = 2; card.mobileW = 8; card.mobileH = 4; card.cardData.friends = []; }, loadData: async (items) => { const allDids = new Set(); for (const item of items) { for (const did of item.cardData.friends ?? []) { allDids.add(did as Did); } } if (allDids.size === 0) return []; const profiles = await Promise.all( Array.from(allDids).map((did) => getBlentoOrBskyProfile({ did }).catch(() => undefined) ) ); return profiles.filter((p) => p && p.handle !== 'handle.invalid'); }, allowSetColor: true, defaultColor: 'base', minW: 2, minH: 2, name: 'Friends', groups: ['Social'], keywords: ['friends', 'avatars', 'people', 'community', 'blentos'], icon: `` } as CardDefinition & { type: 'friends' };