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(
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;

View file

@ -110,9 +110,15 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
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<DesktopReceive> {
}
}
StreamSubscription<Address?>? _streamSub;
@override
void initState() {
walletId = widget.walletId;
@ -238,7 +242,9 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
@override
void dispose() {
_streamSub?.cancel();
for (final subscription in _addressSubMap.values) {
subscription.cancel();
}
super.dispose();
}