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 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) {
</div>
{payService && custom()}
<div className="flex">
{(payService?.commentAllowed ?? 0) > 0 ||
(payService?.nostrPubkey && (
<input
type="text"
placeholder={formatMessage(messages.Comment)}
className="f-grow"
maxLength={payService?.commentAllowed || 120}
onChange={(e) => setComment(e.target.value)}
/>
))}
{canComment && (
<input
type="text"
placeholder={formatMessage(messages.Comment)}
className="f-grow"
maxLength={payService?.commentAllowed || 120}
onChange={(e) => setComment(e.target.value)}
/>
)}
</div>
{(amount ?? 0) > 0 && (
<button

View File

@ -108,24 +108,13 @@ export const Reaction = {
*/
export function normalizeReaction(content: string) {
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 "-":
return Reaction.Negative;
case "👎":
return Reaction.Negative;
default:
return Reaction.Positive;
}
return content;
}
/**