fix: allow zap comments (#229)

This commit is contained in:
Alejandro 2023-02-09 12:32:35 +01:00 committed by GitHub
parent c55ced09d9
commit 61e6876c6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 26 deletions

View File

@ -77,6 +77,8 @@ export default function LNURLTip(props: LNURLTipProps) {
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const publisher = useEventPublisher(); const publisher = useEventPublisher();
const horizontalScroll = useHorizontalScroll(); const horizontalScroll = useHorizontalScroll();
const canComment =
(payService?.commentAllowed ?? 0) > 0 || payService?.nostrPubkey;
useEffect(() => { useEffect(() => {
if (show && !props.invoice) { if (show && !props.invoice) {
@ -150,9 +152,10 @@ export default function LNURLTip(props: LNURLTipProps) {
if (!amount || !payService) return null; if (!amount || !payService) return null;
let url = ""; let url = "";
const amountParam = `amount=${Math.floor(amount * 1000)}`; const amountParam = `amount=${Math.floor(amount * 1000)}`;
const commentParam = comment const commentParam =
? `&comment=${encodeURIComponent(comment)}` comment && payService?.commentAllowed
: ""; ? `&comment=${encodeURIComponent(comment)}`
: "";
if (payService.nostrPubkey && author) { if (payService.nostrPubkey && author) {
const ev = await publisher.zap(author, note, comment); const ev = await publisher.zap(author, note, comment);
const nostrParam = const nostrParam =
@ -241,16 +244,15 @@ export default function LNURLTip(props: LNURLTipProps) {
</div> </div>
{payService && custom()} {payService && custom()}
<div className="flex"> <div className="flex">
{(payService?.commentAllowed ?? 0) > 0 || {canComment && (
(payService?.nostrPubkey && ( <input
<input type="text"
type="text" placeholder={formatMessage(messages.Comment)}
placeholder={formatMessage(messages.Comment)} className="f-grow"
className="f-grow" maxLength={payService?.commentAllowed || 120}
maxLength={payService?.commentAllowed || 120} onChange={(e) => setComment(e.target.value)}
onChange={(e) => setComment(e.target.value)} />
/> )}
))}
</div> </div>
{(amount ?? 0) > 0 && ( {(amount ?? 0) > 0 && (
<button <button

View File

@ -108,24 +108,13 @@ export const Reaction = {
*/ */
export function normalizeReaction(content: string) { export function normalizeReaction(content: string) {
switch (content) { switch (content) {
case "":
return Reaction.Positive;
case "🤙":
return Reaction.Positive;
case "❤️":
return Reaction.Positive;
case "👍":
return Reaction.Positive;
case "💯":
return Reaction.Positive;
case "+":
return Reaction.Positive;
case "-": case "-":
return Reaction.Negative; return Reaction.Negative;
case "👎": case "👎":
return Reaction.Negative; return Reaction.Negative;
default:
return Reaction.Positive;
} }
return content;
} }
/** /**