social components inlay.at
atproto components sdui
86
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 29 lines 918 B view raw
1import { getCurrentDid } from "@/auth"; 2import { resolveDidToHandle } from "@/data"; 3import { AuthChipClient } from "./auth-chip-client"; 4 5async function fetchAvatar(did: string): Promise<string | undefined> { 6 try { 7 const res = await fetch( 8 `https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(did)}`, 9 { signal: AbortSignal.timeout(5000), next: { revalidate: 3600 } } 10 ); 11 if (!res.ok) return undefined; 12 const profile = await res.json(); 13 return profile.avatar?.replace("/img/avatar/", "/img/avatar_thumbnail/"); 14 } catch { 15 return undefined; 16 } 17} 18 19export async function AuthChip() { 20 const did = await getCurrentDid(); 21 if (!did) { 22 return <AuthChipClient user={null} />; 23 } 24 const [handle, avatar] = await Promise.all([ 25 resolveDidToHandle(did), 26 fetchAvatar(did), 27 ]); 28 return <AuthChipClient user={{ did, handle, avatar }} />; 29}