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 [success, setSuccess] = useState<LNURLSuccessAction>();
const [zapType, setZapType] = useState(ZapType.PublicZap);
const [paying, setPaying] = useState<boolean>(false);
const webln = useWebln(show);
const { formatMessage } = useIntl();
const publisher = useEventPublisher();
@ -239,6 +240,7 @@ export default function LNURLTip(props: LNURLTipProps) {
async function payWebLNIfEnabled(invoice: LNURLInvoice) {
try {
if (webln?.enabled) {
setPaying(true);
const res = await webln.sendPayment(invoice?.pr ?? "");
console.log(res);
setSuccess(invoice?.successAction ?? {});
@ -248,6 +250,8 @@ export default function LNURLTip(props: LNURLTipProps) {
if (e instanceof Error) {
setError(e.toString());
}
} finally {
setPaying(false);
}
}
@ -331,7 +335,14 @@ export default function LNURLTip(props: LNURLTipProps) {
<>
<div className="invoice">
{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">
{pr && (
<>

View File

@ -608,6 +608,9 @@
"lD3+8a": {
"defaultMessage": "Pay"
},
"lSpQet": {
"defaultMessage": "Paying with WebLN"
},
"lgg1KN": {
"defaultMessage": "account page"
},
@ -676,6 +679,9 @@
"pzTOmv": {
"defaultMessage": "Followers"
},
"qMx1sA": {
"defaultMessage": "Default Zap amount"
},
"qUJTsT": {
"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!",
"lCILNz": "Buy Now",
"lD3+8a": "Pay",
"lSpQet": "Paying with WebLN",
"lgg1KN": "account page",
"ll3xBp": "Image proxy service",
"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.",
"puLNUJ": "Pin",
"pzTOmv": "Followers",
"qMx1sA": "Default Zap amount",
"qUJTsT": "Blocked",
"qdGuQo": "Your Private Key Is (do not share this with anyone)",
"qkvYUb": "Add to Profile",