From 61e6876c6d7212ea006577153b342c8841dd5c7c Mon Sep 17 00:00:00 2001 From: Alejandro Date: Thu, 9 Feb 2023 12:32:35 +0100 Subject: [PATCH] fix: allow zap comments (#229) --- src/Element/SendSats.tsx | 28 +++++++++++++++------------- src/Util.ts | 15 ++------------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/Element/SendSats.tsx b/src/Element/SendSats.tsx index 1d1f595..3471953 100644 --- a/src/Element/SendSats.tsx +++ b/src/Element/SendSats.tsx @@ -77,6 +77,8 @@ export default function LNURLTip(props: LNURLTipProps) { const { formatMessage } = useIntl(); const publisher = useEventPublisher(); const horizontalScroll = useHorizontalScroll(); + const canComment = + (payService?.commentAllowed ?? 0) > 0 || payService?.nostrPubkey; useEffect(() => { if (show && !props.invoice) { @@ -150,9 +152,10 @@ export default function LNURLTip(props: LNURLTipProps) { if (!amount || !payService) return null; let url = ""; const amountParam = `amount=${Math.floor(amount * 1000)}`; - const commentParam = comment - ? `&comment=${encodeURIComponent(comment)}` - : ""; + const commentParam = + comment && payService?.commentAllowed + ? `&comment=${encodeURIComponent(comment)}` + : ""; if (payService.nostrPubkey && author) { const ev = await publisher.zap(author, note, comment); const nostrParam = @@ -241,16 +244,15 @@ export default function LNURLTip(props: LNURLTipProps) { {payService && custom()}
- {(payService?.commentAllowed ?? 0) > 0 || - (payService?.nostrPubkey && ( - setComment(e.target.value)} - /> - ))} + {canComment && ( + setComment(e.target.value)} + /> + )}
{(amount ?? 0) > 0 && (