From bda09badcff968c36b10baddf3fa12f37e136344 Mon Sep 17 00:00:00 2001 From: codytseng Date: Sun, 9 Mar 2025 10:57:52 +0800 Subject: [PATCH] feat: do not hide the zap button --- src/components/NoteStats/ZapButton.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/NoteStats/ZapButton.tsx b/src/components/NoteStats/ZapButton.tsx index 206a6b9..c23cdb8 100644 --- a/src/components/NoteStats/ZapButton.tsx +++ b/src/components/NoteStats/ZapButton.tsx @@ -28,7 +28,7 @@ export default function ZapButton({ event }: { event: Event }) { hasZapped: pubkey ? stats.zaps?.some((zap) => zap.pubkey === pubkey) : false } }, [noteStatsMap, event, pubkey]) - const [showButton, setShowButton] = useState(false) + const [disable, setDisable] = useState(true) const timerRef = useRef | null>(null) const isLongPressRef = useRef(false) @@ -36,12 +36,10 @@ export default function ZapButton({ event }: { event: Event }) { client.fetchProfile(event.pubkey).then((profile) => { if (!profile) return const lightningAddress = getLightningAddressFromProfile(profile) - if (lightningAddress) setShowButton(true) + if (lightningAddress) setDisable(false) }) }, [event]) - if (!showButton) return null - const handleZap = async () => { try { if (!pubkey) { @@ -74,6 +72,8 @@ export default function ZapButton({ event }: { event: Event }) { const handleClickStart = (e: MouseEvent | TouchEvent) => { e.stopPropagation() e.preventDefault() + if (disable) return + isLongPressRef.current = false if ('touches' in e) { @@ -98,6 +98,7 @@ export default function ZapButton({ event }: { event: Event }) { if (timerRef.current) { clearTimeout(timerRef.current) } + if (disable) return if ('touches' in e) { setTouchStart(null) @@ -129,8 +130,11 @@ export default function ZapButton({ event }: { event: Event }) { <>