fix: receive view bug

This commit is contained in:
julian 2024-11-12 15:38:00 -06:00 committed by julian-CStack
parent 1f0ee995b9
commit 3da57bc150
2 changed files with 19 additions and 7 deletions

View file

@ -113,9 +113,15 @@ class _ReceiveViewState extends ConsumerState<ReceiveView> {
address = await wallet.generateNextReceivingAddress( address = await wallet.generateNextReceivingAddress(
derivePathType: type, derivePathType: type,
); );
await ref.read(mainDBProvider).isar.writeTxn(() async { final isar = ref.read(mainDBProvider).isar;
await ref.read(mainDBProvider).isar.addresses.put(address!); await isar.writeTxn(() async {
await isar.addresses.put(address!);
}); });
final info = ref.read(pWalletInfo(walletId));
await info.updateReceivingAddress(
newAddress: address.value,
isar: isar,
);
} else { } else {
await wallet.generateNewReceivingAddress(); await wallet.generateNewReceivingAddress();
address = null; address = null;

View file

@ -110,9 +110,15 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
address = await wallet.generateNextReceivingAddress( address = await wallet.generateNextReceivingAddress(
derivePathType: type, derivePathType: type,
); );
await ref.read(mainDBProvider).isar.writeTxn(() async { final isar = ref.read(mainDBProvider).isar;
await ref.read(mainDBProvider).isar.addresses.put(address!); await isar.writeTxn(() async {
await isar.addresses.put(address!);
}); });
final info = ref.read(pWalletInfo(walletId));
await info.updateReceivingAddress(
newAddress: address.value,
isar: isar,
);
} else { } else {
await wallet.generateNewReceivingAddress(); await wallet.generateNewReceivingAddress();
address = null; address = null;
@ -172,8 +178,6 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
} }
} }
StreamSubscription<Address?>? _streamSub;
@override @override
void initState() { void initState() {
walletId = widget.walletId; walletId = widget.walletId;
@ -238,7 +242,9 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
@override @override
void dispose() { void dispose() {
_streamSub?.cancel(); for (final subscription in _addressSubMap.values) {
subscription.cancel();
}
super.dispose(); super.dispose();
} }