Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
820 B · 18 lines
TypeScript
12345678910111213141516171819import { useMemo } from "react";import { useAuthor } from "./useAuthor";import { useAvatars } from "./useAvatars";
// Surfaces the author's avatar URL for whatever the player is currently// showing, switching on the player's mode via useAuthor. In both modes we// prefer the hydrated ProfileViewDetailed avatar (fetched through the profile// cache) and fall back to whatever the basic profile/author view carried.// Returns undefined when no avatar is known yet.export function useAvatar(): string | undefined { const author = useAuthor(); const did = author?.did; // memoized so useAvatars' effect doesn't refire on every render const dids = useMemo(() => (did ? [did] : []), [did]); const detailed = useAvatars(dids); if (!did) return undefined; return detailed[did]?.avatar ?? author?.avatar;}