fix(supporters): show shortened npub when a supporter has no profile name

This commit is contained in:
SkateSpots 2026-10-05 17:56:45 +07:00
parent 1bdaa57aa3
commit bf96a9e3a1

View file

@ -213,7 +213,9 @@ function BackerCard({ backer }: { backer: Backer }) {
const meta = data?.metadata; const meta = data?.metadata;
const name = backer.name || meta?.display_name || meta?.name; const name = backer.name || meta?.display_name || meta?.name;
const avatar = backer.logo || meta?.picture; const avatar = backer.logo || meta?.picture;
const initial = (name || 'S').trim().charAt(0).toUpperCase(); const display = name
|| (backer.npub ? `${backer.npub.slice(0, 12)}…${backer.npub.slice(-6)}` : t('walletUi.supporters.anonymousBacker'));
const initial = display.replace(/[^a-zA-Z0-9]/g, '').charAt(0).toUpperCase() || 'S';
const href = backer.npub ? `/${backer.npub}` : backer.url; const href = backer.npub ? `/${backer.npub}` : backer.url;
return ( return (
@ -233,14 +235,14 @@ function BackerCard({ backer }: { backer: Backer }) {
<div className="min-w-0"> <div className="min-w-0">
{href && backer.npub ? ( {href && backer.npub ? (
<Link to={href} className="font-bold text-sm text-white hover:text-[#22d3ee] transition-colors"> <Link to={href} className="font-bold text-sm text-white hover:text-[#22d3ee] transition-colors">
{name || t('walletUi.supporters.anonymousBacker')} {display}
</Link> </Link>
) : href ? ( ) : href ? (
<a href={href} target="_blank" rel="noopener noreferrer" className="font-bold text-sm text-white hover:text-[#22d3ee] transition-colors"> <a href={href} target="_blank" rel="noopener noreferrer" className="font-bold text-sm text-white hover:text-[#22d3ee] transition-colors">
{name || t('walletUi.supporters.anonymousBacker')} {display}
</a> </a>
) : ( ) : (
<p className="font-bold text-sm text-white">{name || t('walletUi.supporters.anonymousBacker')}</p> <p className="font-bold text-sm text-white">{display}</p>
)} )}
{typeof backer.amount === 'number' && ( {typeof backer.amount === 'number' && (
<p className="text-xs font-mono mt-0.5 text-[#22d3ee]/80">{backer.amount.toLocaleString()} sats</p> <p className="text-xs font-mono mt-0.5 text-[#22d3ee]/80">{backer.amount.toLocaleString()} sats</p>