Tor kill switch getter name refactor and bugfix

This commit is contained in:
julian 2023-09-13 10:33:44 -06:00
parent af88673df1
commit 4b518243c6
4 changed files with 17 additions and 12 deletions

View file

@ -190,7 +190,7 @@ class ElectrumX {
// But Tor isn't enabled... // But Tor isn't enabled...
if (!_torService.enabled) { if (!_torService.enabled) {
// And the killswitch isn't set... // 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. // Then we'll just proceed and connect to ElectrumX through clearnet at the bottom of this function.
Logging.instance.log( Logging.instance.log(
"Tor preference set but Tor is not enabled, killswitch not set, connecting to ElectrumX through clearnet", "Tor preference set but Tor is not enabled, killswitch not set, connecting to ElectrumX through clearnet",

View file

@ -170,12 +170,12 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
child: DraggableSwitchButton( child: DraggableSwitchButton(
isOn: ref.watch( isOn: ref.watch(
prefsChangeNotifierProvider prefsChangeNotifierProvider
.select((value) => value.torKillswitch), .select((value) => value.torKillSwitch),
), ),
onValueChanged: (newValue) { onValueChanged: (newValue) {
ref ref
.read(prefsChangeNotifierProvider) .read(prefsChangeNotifierProvider)
.torKillswitch = newValue; .torKillSwitch = newValue;
}, },
), ),
), ),

View file

@ -383,12 +383,12 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
child: DraggableSwitchButton( child: DraggableSwitchButton(
isOn: ref.watch( isOn: ref.watch(
prefsChangeNotifierProvider prefsChangeNotifierProvider
.select((value) => value.torKillswitch), .select((value) => value.torKillSwitch),
), ),
onValueChanged: (newValue) { onValueChanged: (newValue) {
ref ref
.read(prefsChangeNotifierProvider) .read(prefsChangeNotifierProvider)
.torKillswitch = newValue; .torKillSwitch = newValue;
}, },
), ),
), ),

View file

@ -399,14 +399,17 @@ class Prefs extends ChangeNotifier {
// tor // tor
bool _torKillswitch = false; bool _torKillswitch = true;
bool get torKillswitch => _torKillswitch; bool get torKillSwitch => _torKillswitch;
set torKillswitch(bool torKillswitch) { set torKillSwitch(bool torKillswitch) {
if (_torKillswitch != showTestNetCoins) { if (_torKillswitch != torKillswitch) {
DB.instance.put<dynamic>( DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "torKillswitch", value: torKillswitch); boxName: DB.boxNamePrefs,
key: "torKillswitch",
value: torKillswitch,
);
_torKillswitch = torKillswitch; _torKillswitch = torKillswitch;
notifyListeners(); notifyListeners();
} }
@ -414,8 +417,10 @@ class Prefs extends ChangeNotifier {
Future<bool> _getTorKillswitch() async { Future<bool> _getTorKillswitch() async {
return await DB.instance.get<dynamic>( return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "torKillswitch") as bool? ?? boxName: DB.boxNamePrefs,
false; key: "torKillswitch",
) as bool? ??
true;
} }
// show testnet coins // show testnet coins