Fix onSubmit not ignoring payment cancels from WebLN payments (#842)

This commit is contained in:
ekzyis 2024-02-16 19:26:43 +01:00 committed by GitHub
parent 5c56267aaa
commit 3d1bcd38c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -802,7 +802,8 @@ export function Form ({
}
} catch (err) {
const msg = err.message || err.toString?.()
// handle errors from JIT invoices by ignoring them
// ignore errors from JIT invoices or payments from attached wallets
// that mean that submit failed because user aborted the payment
if (msg === 'modal closed' || msg === 'invoice canceled') return
toaster.danger('submit error: ' + msg)
}

View File

@ -293,13 +293,12 @@ export const useInvoiceable = (onSubmit, options = defaultOptions) => {
return onSubmitWrapper
}
const INVOICE_CANCELED_ERROR = 'invoice was canceled'
const INVOICE_CANCELED_ERROR = 'invoice canceled'
const waitForPayment = async ({ invoice, showModal, provider, pollInvoice, gqlCacheUpdate }) => {
if (provider.enabled) {
try {
return await waitForWebLNPayment({ provider, invoice, pollInvoice, gqlCacheUpdate })
} catch (err) {
const INVOICE_CANCELED_ERROR = 'invoice was canceled'
// check for errors which mean that QR code will also fail
if (err.message === INVOICE_CANCELED_ERROR) {
throw err