From 469ab91dfdd829b841eab315ebb8d51552b54aa9 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Tue, 6 Feb 2024 18:53:29 -0600 Subject: [PATCH] exit wallet when backing out from wallet view on mobile --- lib/pages/wallet_view/wallet_view.dart | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index bbb688f01..07d592b33 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -59,6 +59,7 @@ import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/show_loading.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -305,6 +306,26 @@ class _WalletViewState extends ConsumerState { BackupFrequencyType.afterClosingAWallet) { unawaited(ref.read(autoSWBServiceProvider).doBackup()); } + + // Close the wallet according to syncing preferences. + switch (ref.read(prefsChangeNotifierProvider).syncType) { + case SyncingType.currentWalletOnly: + // Close the wallet. + unawaited(ref.watch(pWallets).getWallet(walletId).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(ref.watch(pWallets).getWallet(walletId).exit()); + // unawaited so we don't lag the UI. + } + case SyncingType.allWalletsOnStartup: + // Do nothing. + break; + } } Widget _buildNetworkIcon(WalletSyncStatus status) {