feat: do not hide the zap button
This commit is contained in:
parent
cd62f26a38
commit
bda09badcf
1 changed files with 10 additions and 6 deletions
|
|
@ -28,7 +28,7 @@ export default function ZapButton({ event }: { event: Event }) {
|
||||||
hasZapped: pubkey ? stats.zaps?.some((zap) => zap.pubkey === pubkey) : false
|
hasZapped: pubkey ? stats.zaps?.some((zap) => zap.pubkey === pubkey) : false
|
||||||
}
|
}
|
||||||
}, [noteStatsMap, event, pubkey])
|
}, [noteStatsMap, event, pubkey])
|
||||||
const [showButton, setShowButton] = useState(false)
|
const [disable, setDisable] = useState(true)
|
||||||
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||||
const isLongPressRef = useRef(false)
|
const isLongPressRef = useRef(false)
|
||||||
|
|
||||||
|
|
@ -36,12 +36,10 @@ export default function ZapButton({ event }: { event: Event }) {
|
||||||
client.fetchProfile(event.pubkey).then((profile) => {
|
client.fetchProfile(event.pubkey).then((profile) => {
|
||||||
if (!profile) return
|
if (!profile) return
|
||||||
const lightningAddress = getLightningAddressFromProfile(profile)
|
const lightningAddress = getLightningAddressFromProfile(profile)
|
||||||
if (lightningAddress) setShowButton(true)
|
if (lightningAddress) setDisable(false)
|
||||||
})
|
})
|
||||||
}, [event])
|
}, [event])
|
||||||
|
|
||||||
if (!showButton) return null
|
|
||||||
|
|
||||||
const handleZap = async () => {
|
const handleZap = async () => {
|
||||||
try {
|
try {
|
||||||
if (!pubkey) {
|
if (!pubkey) {
|
||||||
|
|
@ -74,6 +72,8 @@ export default function ZapButton({ event }: { event: Event }) {
|
||||||
const handleClickStart = (e: MouseEvent | TouchEvent) => {
|
const handleClickStart = (e: MouseEvent | TouchEvent) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
if (disable) return
|
||||||
|
|
||||||
isLongPressRef.current = false
|
isLongPressRef.current = false
|
||||||
|
|
||||||
if ('touches' in e) {
|
if ('touches' in e) {
|
||||||
|
|
@ -98,6 +98,7 @@ export default function ZapButton({ event }: { event: Event }) {
|
||||||
if (timerRef.current) {
|
if (timerRef.current) {
|
||||||
clearTimeout(timerRef.current)
|
clearTimeout(timerRef.current)
|
||||||
}
|
}
|
||||||
|
if (disable) return
|
||||||
|
|
||||||
if ('touches' in e) {
|
if ('touches' in e) {
|
||||||
setTouchStart(null)
|
setTouchStart(null)
|
||||||
|
|
@ -129,8 +130,11 @@ export default function ZapButton({ event }: { event: Event }) {
|
||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex items-center enabled:hover:text-yellow-400 gap-1 select-none px-3 h-full',
|
'flex items-center gap-1 select-none px-3 h-full',
|
||||||
hasZapped ? 'text-yellow-400' : 'text-muted-foreground'
|
hasZapped ? 'text-yellow-400' : 'text-muted-foreground',
|
||||||
|
disable
|
||||||
|
? 'cursor-not-allowed text-muted-foreground/40'
|
||||||
|
: 'cursor-pointer enabled:hover:text-yellow-400'
|
||||||
)}
|
)}
|
||||||
title={t('Zap')}
|
title={t('Zap')}
|
||||||
onMouseDown={handleClickStart}
|
onMouseDown={handleClickStart}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue