From 8f89d4956f06bbfd47e2f04ee5d69c1ca2160f07 Mon Sep 17 00:00:00 2001 From: franzap <_@franzap.com> Date: Tue, 7 Jan 2025 18:42:40 -0300 Subject: [PATCH] If timeout is thrown, tell the user the invoice still may get paid --- lib/models/user.dart | 1 - lib/widgets/zap_button.dart | 9 ++++++++- lib/widgets/zap_receipts.dart | 3 +-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/models/user.dart b/lib/models/user.dart index e4ce3fa..da3f4c5 100644 --- a/lib/models/user.dart +++ b/lib/models/user.dart @@ -116,7 +116,6 @@ class User extends base.User with DataModelMixin { } // Pay the invoice via NWC (errors are thrown) - // TODO: If timeout is thrown, tell the user the invoice still may get paid await adapter.socialRelays.ndk!.nwc.payInvoice(nwcConnection, invoice: invoice, timeout: Duration(seconds: 20)); } diff --git a/lib/widgets/zap_button.dart b/lib/widgets/zap_button.dart index 0707f49..63b985b 100644 --- a/lib/widgets/zap_button.dart +++ b/lib/widgets/zap_button.dart @@ -186,8 +186,15 @@ class ZapButton extends HookConsumerWidget { context.showInfo('$amount sat${amount > 1 ? 's' : ''} sent!', description: 'Payment was successful'); } catch (e) { + var title = 'Unable to zap'; + var description = e.toString(); + if (e.toString().contains('Timed out')) { + title = 'Unknown state'; + description = + 'The call timed out but payment may still go through! Please watch the zaps list.\n\n$description'; + } // ignore: use_build_context_synchronously - context.showError('Unable to zap', description: e.toString()); + context.showError(title, description: description); } } }, diff --git a/lib/widgets/zap_receipts.dart b/lib/widgets/zap_receipts.dart index 4f6b703..ecd6054 100644 --- a/lib/widgets/zap_receipts.dart +++ b/lib/widgets/zap_receipts.dart @@ -72,7 +72,6 @@ class ZapReceipts extends HookConsumerWidget { final totalUserAmount = receipts .where((r) => u.pubkey == r.senderPubkey) .fold(0, (acc, e) => acc + e.amount); - print('$totalUserAmount - ${u.nameOrNpub}'); return totalUserAmount.wrapped; }); @@ -97,7 +96,7 @@ class ZapReceipts extends HookConsumerWidget { Widget _wrap(Widget inner) { return Padding( - padding: const EdgeInsets.only(top: 10, bottom: 20), + padding: const EdgeInsets.only(top: 10, bottom: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, spacing: 10,