From 3da57bc150d6994f02ff9e91a9d3b14f71ed9ea0 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 12 Nov 2024 15:38:00 -0600 Subject: [PATCH] fix: receive view bug --- lib/pages/receive_view/receive_view.dart | 10 ++++++++-- .../wallet_view/sub_widgets/desktop_receive.dart | 16 +++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/pages/receive_view/receive_view.dart b/lib/pages/receive_view/receive_view.dart index a40262cdc..cbfd1763e 100644 --- a/lib/pages/receive_view/receive_view.dart +++ b/lib/pages/receive_view/receive_view.dart @@ -113,9 +113,15 @@ class _ReceiveViewState extends ConsumerState { address = await wallet.generateNextReceivingAddress( derivePathType: type, ); - await ref.read(mainDBProvider).isar.writeTxn(() async { - await ref.read(mainDBProvider).isar.addresses.put(address!); + final isar = ref.read(mainDBProvider).isar; + await isar.writeTxn(() async { + await isar.addresses.put(address!); }); + final info = ref.read(pWalletInfo(walletId)); + await info.updateReceivingAddress( + newAddress: address.value, + isar: isar, + ); } else { await wallet.generateNewReceivingAddress(); address = null; diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart index a96a01b8f..7c003e7f2 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart @@ -110,9 +110,15 @@ class _DesktopReceiveState extends ConsumerState { address = await wallet.generateNextReceivingAddress( derivePathType: type, ); - await ref.read(mainDBProvider).isar.writeTxn(() async { - await ref.read(mainDBProvider).isar.addresses.put(address!); + final isar = ref.read(mainDBProvider).isar; + await isar.writeTxn(() async { + await isar.addresses.put(address!); }); + final info = ref.read(pWalletInfo(walletId)); + await info.updateReceivingAddress( + newAddress: address.value, + isar: isar, + ); } else { await wallet.generateNewReceivingAddress(); address = null; @@ -172,8 +178,6 @@ class _DesktopReceiveState extends ConsumerState { } } - StreamSubscription? _streamSub; - @override void initState() { walletId = widget.walletId; @@ -238,7 +242,9 @@ class _DesktopReceiveState extends ConsumerState { @override void dispose() { - _streamSub?.cancel(); + for (final subscription in _addressSubMap.values) { + subscription.cancel(); + } super.dispose(); }