From 3d1bcd38c606d9484d68394bbdce9da5da76de5f Mon Sep 17 00:00:00 2001 From: ekzyis Date: Fri, 16 Feb 2024 19:26:43 +0100 Subject: [PATCH] Fix onSubmit not ignoring payment cancels from WebLN payments (#842) --- components/form.js | 3 ++- components/invoice.js | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/form.js b/components/form.js index 425ee255..4144f771 100644 --- a/components/form.js +++ b/components/form.js @@ -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) } diff --git a/components/invoice.js b/components/invoice.js index a356e4c3..e8565e3f 100644 --- a/components/invoice.js +++ b/components/invoice.js @@ -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