Remove unused useWallet from QR code component (#1660)

This commit is contained in:
ekzyis 2024-11-28 00:16:44 +01:00 committed by GitHub
parent 707d7bdf8b
commit 5e76ee1844
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 25 deletions

View File

@ -19,7 +19,7 @@ import styles from './invoice.module.css'
export default function Invoice ({
id, query = INVOICE, modal, onPayment, onExpired, onCanceled, info, successVerb = 'deposited',
heldVerb = 'settling', useWallet = true, walletError, poll, waitFor, ...props
heldVerb = 'settling', walletError, poll, waitFor, ...props
}) {
const { data, error } = useQuery(query, SSR
? {}
@ -79,15 +79,12 @@ export default function Invoice ({
{invoice.forwardedSats && <Badge className={styles.badge} bg={null}>p2p</Badge>}
</>
)
useWallet = false
} else if (expired) {
variant = 'failed'
status = 'expired'
useWallet = false
} else if (invoice.cancelled) {
variant = 'failed'
status = 'cancelled'
useWallet = false
} else if (invoice.isHeld) {
variant = 'pending'
status = (
@ -95,7 +92,6 @@ export default function Invoice ({
<Moon className='spin fill-grey me-2' /> {heldVerb}
</div>
)
useWallet = false
} else {
variant = 'pending'
status = (
@ -113,7 +109,7 @@ export default function Invoice ({
<code> {walletError.message}</code>
</div>}
<Qr
useWallet={useWallet} value={invoice.bolt11}
value={invoice.bolt11}
description={numWithUnits(invoice.satsRequested, { abbreviate: false })}
statusVariant={variant} status={status}
/>

View File

@ -150,7 +150,6 @@ export const useQrPayment = () => {
description
status='loading'
successVerb='received'
useWallet={false}
walletError={walletError}
waitFor={waitFor}
onExpired={inv => reject(new InvoiceExpiredError(inv?.hash))}

View File

@ -1,8 +1,6 @@
import { QRCodeSVG } from 'qrcode.react'
import { CopyInput, InputSkeleton } from './form'
import InvoiceStatus from './invoice-status'
import { useEffect } from 'react'
import { useWallet } from '@/wallets/index'
import Bolt11Info from './bolt11-info'
export const qrImageSettings = {
@ -14,22 +12,8 @@ export const qrImageSettings = {
excavate: true
}
export default function Qr ({ asIs, value, useWallet: automated, statusVariant, description, status }) {
export default function Qr ({ asIs, value, statusVariant, description, status }) {
const qrValue = asIs ? value : 'lightning:' + value.toUpperCase()
const wallet = useWallet()
useEffect(() => {
async function effect () {
if (automated && wallet) {
try {
await wallet.sendPayment(value)
} catch (e) {
console.log(e?.message)
}
}
}
effect()
}, [wallet])
return (
<>

View File

@ -12,7 +12,7 @@ export default function FullInvoice () {
return (
<CenterLayout>
<Invoice id={router.query.id} query={INVOICE_FULL} poll description status='loading' bolt11Info useWallet={false} />
<Invoice id={router.query.id} query={INVOICE_FULL} poll description status='loading' bolt11Info />
</CenterLayout>
)
}