diff --git a/src/components/ZapButton.tsx b/src/components/ZapButton.tsx index bb3bbd8..134ffb7 100644 --- a/src/components/ZapButton.tsx +++ b/src/components/ZapButton.tsx @@ -24,21 +24,44 @@ export function ZapButton({ const { webln, activeNWC } = useWallet(); // Only fetch data if not provided externally - const { totalSats: fetchedTotalSats, isLoading } = useZaps( + const { totalSats: fetchedTotalSats, zapCount: fetchedZapCount, isLoading } = useZaps( externalZapData ? [] : target ?? [], // Empty array prevents fetching if external data provided webln, activeNWC ); - // Don't show zap button if user is not logged in, is the author, or author has no lightning address - if (!user || !target || user.pubkey === target.pubkey || (!author?.metadata?.lud16 && !author?.metadata?.lud06)) { + if (!target) { return null; } // Use external data if provided, otherwise use fetched data const totalSats = externalZapData?.totalSats ?? fetchedTotalSats; + const zapCount = externalZapData?.count ?? fetchedZapCount; const showLoading = externalZapData?.isLoading || isLoading; + const hasLightning = !!(author?.metadata?.lud16 || author?.metadata?.lud06); + const canZap = !!user && user.pubkey !== target.pubkey && hasLightning; + + /** + * Read-only total. Zaps are social proof, so the count is shown to EVERYONE — + * logged-out visitors included — not just to people who can zap. This costs + * no extra network work: `useZaps` already runs above regardless of login. + */ + if (!canZap) { + if (!showCount || showLoading || totalSats <= 0) { + return null; + } + return ( + + + {totalSats.toLocaleString()} + + ); + } + return (