fix(supporters): resolve avatars by hex pubkey (was passing npub to useAuthor)

This commit is contained in:
SkateSpots 2026-10-05 19:06:22 +07:00
parent cc1883cf82
commit 34cf930657

View file

@ -22,6 +22,17 @@ const ANGOR_PROJECT_URL = 'https://angor.io/project/angor1qtunna00uqyx52rr0nvqa0
const SUPPORTERS_SINCE = Math.floor(Date.UTC(2025, 11, 1) / 1000); // 2025-12-01
const VISIBLE_LIMIT = 21;
/** npub → hex pubkey (useAuthor queries relays by HEX authors). */
function npubToHex(npub?: string): string | undefined {
if (!npub) return undefined;
try {
const d = nip19.decode(npub);
return d.type === 'npub' ? d.data : undefined;
} catch {
return undefined;
}
}
// ─── Static data — edit these arrays to add/remove entries ──────────────────
interface Collaborator {
@ -233,6 +244,7 @@ function FriendCard({ friend }: { friend: Friend }) {
interface SupporterEntry {
key: string;
pubkey?: string;
npub?: string;
name?: string;
logo?: string;
@ -261,7 +273,7 @@ const TIER_RANGE: Record<(typeof TIER_ORDER)[number], string> = {
};
function MemberAvatar({ entry }: { entry: SupporterEntry }) {
const { data } = useAuthor(entry.anonymous ? undefined : entry.npub);
const { data } = useAuthor(entry.anonymous ? undefined : entry.pubkey);
const meta = data?.metadata;
const name = entry.anonymous
? '★'
@ -321,7 +333,7 @@ function TierLadder({ supporters }: { supporters: SupporterEntry[] }) {
function SupporterRow({ rank, entry }: { rank: number; entry: SupporterEntry }) {
const { t } = useTranslation();
const { data } = useAuthor(entry.anonymous ? undefined : entry.npub);
const { data } = useAuthor(entry.anonymous ? undefined : entry.pubkey);
const meta = data?.metadata;
const name = entry.anonymous
? t('walletUi.supporters.anonymousBacker')
@ -435,6 +447,7 @@ export default function SupportersPage() {
const key = (npub || b.url || b.name || `anon-${i}`).toLowerCase();
map.set(key, {
key,
pubkey: npub ? npubToHex(npub) : undefined,
npub,
name: b.anonymous ? undefined : b.name,
logo: b.anonymous ? undefined : b.logo,
@ -458,6 +471,7 @@ export default function SupportersPage() {
} else {
map.set(npub, {
key: npub,
pubkey: z.pubkey,
npub,
sats: z.sats,
angorSats: 0,