From 4b518243c6bb3d71624d9b15c007b24f8f0d9777 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 13 Sep 2023 10:33:44 -0600 Subject: [PATCH] Tor kill switch getter name refactor and bugfix --- lib/electrumx_rpc/electrumx.dart | 2 +- .../tor_settings/tor_settings_view.dart | 4 ++-- .../tor_settings/tor_settings.dart | 4 ++-- lib/utilities/prefs.dart | 19 ++++++++++++------- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/electrumx_rpc/electrumx.dart b/lib/electrumx_rpc/electrumx.dart index 7ee8063cd..292679342 100644 --- a/lib/electrumx_rpc/electrumx.dart +++ b/lib/electrumx_rpc/electrumx.dart @@ -190,7 +190,7 @@ class ElectrumX { // But Tor isn't enabled... if (!_torService.enabled) { // And the killswitch isn't set... - if (!_prefs.torKillswitch) { + if (!_prefs.torKillSwitch) { // Then we'll just proceed and connect to ElectrumX through clearnet at the bottom of this function. Logging.instance.log( "Tor preference set but Tor is not enabled, killswitch not set, connecting to ElectrumX through clearnet", diff --git a/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart b/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart index 30643f605..097a68b93 100644 --- a/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart +++ b/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart @@ -170,12 +170,12 @@ class _TorSettingsViewState extends ConsumerState { child: DraggableSwitchButton( isOn: ref.watch( prefsChangeNotifierProvider - .select((value) => value.torKillswitch), + .select((value) => value.torKillSwitch), ), onValueChanged: (newValue) { ref .read(prefsChangeNotifierProvider) - .torKillswitch = newValue; + .torKillSwitch = newValue; }, ), ), diff --git a/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart index 03c1ee841..212387035 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart @@ -383,12 +383,12 @@ class _TorSettingsState extends ConsumerState { child: DraggableSwitchButton( isOn: ref.watch( prefsChangeNotifierProvider - .select((value) => value.torKillswitch), + .select((value) => value.torKillSwitch), ), onValueChanged: (newValue) { ref .read(prefsChangeNotifierProvider) - .torKillswitch = newValue; + .torKillSwitch = newValue; }, ), ), diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index 027c6037d..583d9804b 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -399,14 +399,17 @@ class Prefs extends ChangeNotifier { // tor - bool _torKillswitch = false; + bool _torKillswitch = true; - bool get torKillswitch => _torKillswitch; + bool get torKillSwitch => _torKillswitch; - set torKillswitch(bool torKillswitch) { - if (_torKillswitch != showTestNetCoins) { + set torKillSwitch(bool torKillswitch) { + if (_torKillswitch != torKillswitch) { DB.instance.put( - boxName: DB.boxNamePrefs, key: "torKillswitch", value: torKillswitch); + boxName: DB.boxNamePrefs, + key: "torKillswitch", + value: torKillswitch, + ); _torKillswitch = torKillswitch; notifyListeners(); } @@ -414,8 +417,10 @@ class Prefs extends ChangeNotifier { Future _getTorKillswitch() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "torKillswitch") as bool? ?? - false; + boxName: DB.boxNamePrefs, + key: "torKillswitch", + ) as bool? ?? + true; } // show testnet coins