From e93891682bd946019b7be80a6632198ee7161373 Mon Sep 17 00:00:00 2001 From: Matthew Fosse Date: Tue, 2 Jan 2024 12:31:05 -0500 Subject: [PATCH] save --- lib/entities/preferences_key.dart | 1 + .../settings/connection_sync_page.dart | 20 ++++++++++--------- lib/store/settings_store.dart | 7 +++++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/entities/preferences_key.dart b/lib/entities/preferences_key.dart index 7da843d79..90787490c 100644 --- a/lib/entities/preferences_key.dart +++ b/lib/entities/preferences_key.dart @@ -48,6 +48,7 @@ class PreferencesKey { static const moneroWalletPasswordUpdateV1Base = 'monero_wallet_update_v1'; static const syncModeKey = 'sync_mode'; static const syncAllKey = 'sync_all'; + static const torConnectionKey = 'tor_connection'; static const pinTimeOutDuration = 'pin_timeout_duration'; static const lastAuthTimeMilliseconds = 'last_auth_time_milliseconds'; static const lastPopupDate = 'last_popup_date'; diff --git a/lib/src/screens/settings/connection_sync_page.dart b/lib/src/screens/settings/connection_sync_page.dart index 5ef878bdd..cd667f8cf 100644 --- a/lib/src/screens/settings/connection_sync_page.dart +++ b/lib/src/screens/settings/connection_sync_page.dart @@ -91,18 +91,20 @@ class ConnectionSyncPage extends BasePage { const StandardListSeparator(padding: EdgeInsets.symmetric(horizontal: 24)), ], if (FeatureFlag.isInAppTorEnabled) ...[ - Observer(builder: (context) { - return SettingsPickerCell( - title: S.current.background_sync_mode, - items: TorConnection.all, - displayItem: (TorConnection torConnection) => torConnection.name, - selectedItem: dashboardViewModel.torConnection, - onItemSelected: dashboardViewModel.setTorConnection, - ); - }), Container( color: Colors.amber, // TODO: CW-519 change + padding: EdgeInsets.symmetric(horizontal: 24, vertical: 10), + child: Column(children: [ + Observer(builder: (context) { + return SettingsPickerCell( + title: S.current.background_sync_mode, + items: TorConnection.all, + displayItem: (TorConnection torConnection) => torConnection.name, + selectedItem: dashboardViewModel.torConnection, + onItemSelected: dashboardViewModel.setTorConnection, + ); + }), SettingsCellWithArrow( title: S.current.tor_connection, handler: (context) => Navigator.of(context).pushNamed(Routes.torPage), diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index 314583210..149f4010d 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -70,6 +70,7 @@ abstract class SettingsStoreBase with Store { required String initialLanguageCode, required SyncMode initialSyncMode, required bool initialSyncAll, + required TorConnection initialTorConnection, // required String initialCurrentLocale, required this.appVersion, required this.deviceName, @@ -151,6 +152,7 @@ abstract class SettingsStoreBase with Store { initialShouldRequireTOTP2FAForAllSecurityAndBackupSettings, currentSyncMode = initialSyncMode, currentSyncAll = initialSyncAll, + currentTorConnection = initialTorConnection, priority = ObservableMap(), defaultBuyProviders = ObservableMap(), defaultSellProviders = ObservableMap() { @@ -944,6 +946,10 @@ abstract class SettingsStoreBase with Store { }); final savedSyncAll = sharedPreferences.getBool(PreferencesKey.syncAllKey) ?? true; + final savedTorConnection = TorConnection.all.firstWhere((element) { + return element.type.index == (sharedPreferences.getInt(PreferencesKey.torConnectionKey) ?? 0); + }); + return SettingsStore( sharedPreferences: sharedPreferences, initialShouldShowMarketPlaceInDashboard: shouldShowMarketPlaceInDashboard, @@ -1011,6 +1017,7 @@ abstract class SettingsStoreBase with Store { backgroundTasks: backgroundTasks, initialSyncMode: savedSyncMode, initialSyncAll: savedSyncAll, + initialTorConnection: savedTorConnection, shouldShowYatPopup: shouldShowYatPopup); }