feat: hide QR when WebLN triggered

This commit is contained in:
Kieran 2023-02-24 23:24:18 +00:00
parent 44b29b777d
commit df04c16283
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
3 changed files with 20 additions and 1 deletions

View File

@ -93,6 +93,7 @@ export default function LNURLTip(props: LNURLTipProps) {
const [error, setError] = useState<string>(); const [error, setError] = useState<string>();
const [success, setSuccess] = useState<LNURLSuccessAction>(); const [success, setSuccess] = useState<LNURLSuccessAction>();
const [zapType, setZapType] = useState(ZapType.PublicZap); const [zapType, setZapType] = useState(ZapType.PublicZap);
const [paying, setPaying] = useState<boolean>(false);
const webln = useWebln(show); const webln = useWebln(show);
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const publisher = useEventPublisher(); const publisher = useEventPublisher();
@ -239,6 +240,7 @@ export default function LNURLTip(props: LNURLTipProps) {
async function payWebLNIfEnabled(invoice: LNURLInvoice) { async function payWebLNIfEnabled(invoice: LNURLInvoice) {
try { try {
if (webln?.enabled) { if (webln?.enabled) {
setPaying(true);
const res = await webln.sendPayment(invoice?.pr ?? ""); const res = await webln.sendPayment(invoice?.pr ?? "");
console.log(res); console.log(res);
setSuccess(invoice?.successAction ?? {}); setSuccess(invoice?.successAction ?? {});
@ -248,6 +250,8 @@ export default function LNURLTip(props: LNURLTipProps) {
if (e instanceof Error) { if (e instanceof Error) {
setError(e.toString()); setError(e.toString());
} }
} finally {
setPaying(false);
} }
} }
@ -331,7 +335,14 @@ export default function LNURLTip(props: LNURLTipProps) {
<> <>
<div className="invoice"> <div className="invoice">
{props.notice && <b className="error">{props.notice}</b>} {props.notice && <b className="error">{props.notice}</b>}
<QrCode data={pr} link={`lightning:${pr}`} /> {paying ? (
<h4>
<FormattedMessage defaultMessage="Paying with WebLN" />
...
</h4>
) : (
<QrCode data={pr} link={`lightning:${pr}`} />
)}
<div className="actions"> <div className="actions">
{pr && ( {pr && (
<> <>

View File

@ -608,6 +608,9 @@
"lD3+8a": { "lD3+8a": {
"defaultMessage": "Pay" "defaultMessage": "Pay"
}, },
"lSpQet": {
"defaultMessage": "Paying with WebLN"
},
"lgg1KN": { "lgg1KN": {
"defaultMessage": "account page" "defaultMessage": "account page"
}, },
@ -676,6 +679,9 @@
"pzTOmv": { "pzTOmv": {
"defaultMessage": "Followers" "defaultMessage": "Followers"
}, },
"qMx1sA": {
"defaultMessage": "Default Zap amount"
},
"qUJTsT": { "qUJTsT": {
"defaultMessage": "Blocked" "defaultMessage": "Blocked"
}, },

View File

@ -198,6 +198,7 @@
"k7sKNy": "Our very own NIP-05 verification service, help support the development of this site and get a shiny special badge on our site!", "k7sKNy": "Our very own NIP-05 verification service, help support the development of this site and get a shiny special badge on our site!",
"lCILNz": "Buy Now", "lCILNz": "Buy Now",
"lD3+8a": "Pay", "lD3+8a": "Pay",
"lSpQet": "Paying with WebLN",
"lgg1KN": "account page", "lgg1KN": "account page",
"ll3xBp": "Image proxy service", "ll3xBp": "Image proxy service",
"lnaT9F": "Following {n}", "lnaT9F": "Following {n}",
@ -220,6 +221,7 @@
"oxCa4R": "Getting an identifier helps confirm the real you to people who know you. Many people can have a username @jack, but there is only one jack@cash.app.", "oxCa4R": "Getting an identifier helps confirm the real you to people who know you. Many people can have a username @jack, but there is only one jack@cash.app.",
"puLNUJ": "Pin", "puLNUJ": "Pin",
"pzTOmv": "Followers", "pzTOmv": "Followers",
"qMx1sA": "Default Zap amount",
"qUJTsT": "Blocked", "qUJTsT": "Blocked",
"qdGuQo": "Your Private Key Is (do not share this with anyone)", "qdGuQo": "Your Private Key Is (do not share this with anyone)",
"qkvYUb": "Add to Profile", "qkvYUb": "Add to Profile",