exit wallet when backing out from wallet view on desktop

This commit is contained in:
sneurlax 2024-02-06 15:07:51 -06:00
parent e27612b45f
commit f81e432d33

View file

@ -38,6 +38,7 @@ import 'package:stackwallet/themes/coin_icon_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
import 'package:stackwallet/utilities/enums/sync_type_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
import 'package:stackwallet/wallets/wallet/impl/banano_wallet.dart'; import 'package:stackwallet/wallets/wallet/impl/banano_wallet.dart';
@ -93,6 +94,26 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
unawaited(ref.read(autoSWBServiceProvider).doBackup()); unawaited(ref.read(autoSWBServiceProvider).doBackup());
} }
// Close the wallet according to syncing preferences.
switch (ref.read(prefsChangeNotifierProvider).syncType) {
case SyncingType.currentWalletOnly:
// Close the wallet.
unawaited(wallet.exit());
// unawaited so we don't lag the UI.
case SyncingType.selectedWalletsAtStartup:
// Close if this wallet is not in the list to be synced.
if (!ref
.read(prefsChangeNotifierProvider)
.walletIdsSyncOnStartup
.contains(widget.walletId)) {
unawaited(wallet.exit());
// unawaited so we don't lag the UI.
}
case SyncingType.allWalletsOnStartup:
// Do nothing.
break;
}
ref.read(currentWalletIdProvider.notifier).state = null; ref.read(currentWalletIdProvider.notifier).state = null;
} }