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 SUPPORTERS_SINCE = Math.floor(Date.UTC(2025, 11, 1) / 1000); // 2025-12-01
const VISIBLE_LIMIT = 21; 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 ────────────────── // ─── Static data — edit these arrays to add/remove entries ──────────────────
interface Collaborator { interface Collaborator {
@ -233,6 +244,7 @@ function FriendCard({ friend }: { friend: Friend }) {
interface SupporterEntry { interface SupporterEntry {
key: string; key: string;
pubkey?: string;
npub?: string; npub?: string;
name?: string; name?: string;
logo?: string; logo?: string;
@ -261,7 +273,7 @@ const TIER_RANGE: Record<(typeof TIER_ORDER)[number], string> = {
}; };
function MemberAvatar({ entry }: { entry: SupporterEntry }) { 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 meta = data?.metadata;
const name = entry.anonymous const name = entry.anonymous
? '★' ? '★'
@ -321,7 +333,7 @@ function TierLadder({ supporters }: { supporters: SupporterEntry[] }) {
function SupporterRow({ rank, entry }: { rank: number; entry: SupporterEntry }) { function SupporterRow({ rank, entry }: { rank: number; entry: SupporterEntry }) {
const { t } = useTranslation(); const { t } = useTranslation();
const { data } = useAuthor(entry.anonymous ? undefined : entry.npub); const { data } = useAuthor(entry.anonymous ? undefined : entry.pubkey);
const meta = data?.metadata; const meta = data?.metadata;
const name = entry.anonymous const name = entry.anonymous
? t('walletUi.supporters.anonymousBacker') ? t('walletUi.supporters.anonymousBacker')
@ -435,6 +447,7 @@ export default function SupportersPage() {
const key = (npub || b.url || b.name || `anon-${i}`).toLowerCase(); const key = (npub || b.url || b.name || `anon-${i}`).toLowerCase();
map.set(key, { map.set(key, {
key, key,
pubkey: npub ? npubToHex(npub) : undefined,
npub, npub,
name: b.anonymous ? undefined : b.name, name: b.anonymous ? undefined : b.name,
logo: b.anonymous ? undefined : b.logo, logo: b.anonymous ? undefined : b.logo,
@ -458,6 +471,7 @@ export default function SupportersPage() {
} else { } else {
map.set(npub, { map.set(npub, {
key: npub, key: npub,
pubkey: z.pubkey,
npub, npub,
sats: z.sats, sats: z.sats,
angorSats: 0, angorSats: 0,