small review changes

This commit is contained in:
Matthew Fosse 2024-03-01 08:25:00 -08:00
parent a97b84ee82
commit e737116402
6 changed files with 4 additions and 35 deletions

View file

@ -219,7 +219,6 @@ class BackupService {
final displayActionListMode = data[PreferencesKey.displayActionListModeKey] as int?; final displayActionListMode = data[PreferencesKey.displayActionListModeKey] as int?;
final fiatApiMode = data[PreferencesKey.currentFiatApiModeKey] as int?; final fiatApiMode = data[PreferencesKey.currentFiatApiModeKey] as int?;
final torConnectionMode = data[PreferencesKey.currentTorConnectionModeKey] as int?; final torConnectionMode = data[PreferencesKey.currentTorConnectionModeKey] as int?;
final shouldStartTorOnLaunch = data[PreferencesKey.shouldStartTorOnLaunch] as bool?;
final currentPinLength = data[PreferencesKey.currentPinLength] as int?; final currentPinLength = data[PreferencesKey.currentPinLength] as int?;
final currentTheme = data[PreferencesKey.currentTheme] as int?; final currentTheme = data[PreferencesKey.currentTheme] as int?;
final exchangeStatus = data[PreferencesKey.exchangeStatusKey] as int?; final exchangeStatus = data[PreferencesKey.exchangeStatusKey] as int?;
@ -295,10 +294,6 @@ class BackupService {
if (torConnectionMode != null) if (torConnectionMode != null)
await _sharedPreferences.setInt(PreferencesKey.currentTorConnectionModeKey, torConnectionMode); await _sharedPreferences.setInt(PreferencesKey.currentTorConnectionModeKey, torConnectionMode);
if (shouldStartTorOnLaunch != null)
await _sharedPreferences.setBool(
PreferencesKey.shouldStartTorOnLaunch, shouldStartTorOnLaunch);
if (autoGenerateSubaddressStatus != null) if (autoGenerateSubaddressStatus != null)
await _sharedPreferences.setInt( await _sharedPreferences.setInt(
PreferencesKey.autoGenerateSubaddressStatusKey, autoGenerateSubaddressStatus); PreferencesKey.autoGenerateSubaddressStatusKey, autoGenerateSubaddressStatus);
@ -495,8 +490,6 @@ class BackupService {
_sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey), _sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey),
PreferencesKey.currentTorConnectionModeKey: PreferencesKey.currentTorConnectionModeKey:
_sharedPreferences.getInt(PreferencesKey.currentTorConnectionModeKey), _sharedPreferences.getInt(PreferencesKey.currentTorConnectionModeKey),
PreferencesKey.shouldStartTorOnLaunch:
_sharedPreferences.getBool(PreferencesKey.shouldStartTorOnLaunch),
PreferencesKey.sortBalanceBy: _sharedPreferences.getInt(PreferencesKey.sortBalanceBy), PreferencesKey.sortBalanceBy: _sharedPreferences.getInt(PreferencesKey.sortBalanceBy),
PreferencesKey.pinNativeTokenAtTop: PreferencesKey.pinNativeTokenAtTop:
_sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop), _sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop),

View file

@ -13,6 +13,7 @@ import 'package:cake_wallet/core/yat_service.dart';
import 'package:cake_wallet/entities/background_tasks.dart'; import 'package:cake_wallet/entities/background_tasks.dart';
import 'package:cake_wallet/entities/exchange_api_mode.dart'; import 'package:cake_wallet/entities/exchange_api_mode.dart';
import 'package:cake_wallet/entities/parse_address_from_domain.dart'; import 'package:cake_wallet/entities/parse_address_from_domain.dart';
import 'package:cake_wallet/view_model/settings/tor_connection.dart';
import 'package:cw_core/receive_page_option.dart'; import 'package:cw_core/receive_page_option.dart';
import 'package:cake_wallet/ethereum/ethereum.dart'; import 'package:cake_wallet/ethereum/ethereum.dart';
import 'package:cake_wallet/nano/nano.dart'; import 'package:cake_wallet/nano/nano.dart';
@ -730,7 +731,9 @@ Future<void> setup({
torViewModel: getIt.get<TorViewModel>(), torViewModel: getIt.get<TorViewModel>(),
)); ));
if (DeviceInfo.instance.isMobile && settingsStore.shouldStartTorOnLaunch) { if (DeviceInfo.instance.isMobile &&
(settingsStore.torConnectionMode == TorConnectionMode.enabled ||
settingsStore.torConnectionMode == TorConnectionMode.torOnly)) {
getIt.get<TorViewModel>().startTor(); getIt.get<TorViewModel>().startTor();
} }

View file

@ -24,7 +24,6 @@ class PreferencesKey {
static const walletListOrder = 'wallet_list_order'; static const walletListOrder = 'wallet_list_order';
static const walletListAscending = 'wallet_list_ascending'; static const walletListAscending = 'wallet_list_ascending';
static const currentFiatApiModeKey = 'current_fiat_api_mode'; static const currentFiatApiModeKey = 'current_fiat_api_mode';
static const shouldStartTorOnLaunch = 'start_tor_on_launch';
static const currentTorConnectionModeKey = 'current_tor_connection_mode'; static const currentTorConnectionModeKey = 'current_tor_connection_mode';
static const failedTotpTokenTrials = 'failed_token_trials'; static const failedTotpTokenTrials = 'failed_token_trials';
static const disableExchangeKey = 'disable_exchange'; static const disableExchangeKey = 'disable_exchange';

View file

@ -64,7 +64,6 @@ abstract class SettingsStoreBase with Store {
required bool initialWalletListAscending, required bool initialWalletListAscending,
required FiatApiMode initialFiatMode, required FiatApiMode initialFiatMode,
required TorConnectionMode initialTorConnectionMode, required TorConnectionMode initialTorConnectionMode,
required bool initialShouldStartTorOnLaunch,
required bool initialAllowBiometricalAuthentication, required bool initialAllowBiometricalAuthentication,
required String initialTotpSecretKey, required String initialTotpSecretKey,
required bool initialUseTOTP2FA, required bool initialUseTOTP2FA,
@ -126,7 +125,6 @@ abstract class SettingsStoreBase with Store {
moneroSeedType = initialMoneroSeedType, moneroSeedType = initialMoneroSeedType,
fiatApiMode = initialFiatMode, fiatApiMode = initialFiatMode,
torConnectionMode = initialTorConnectionMode, torConnectionMode = initialTorConnectionMode,
shouldStartTorOnLaunch = initialShouldStartTorOnLaunch,
allowBiometricalAuthentication = initialAllowBiometricalAuthentication, allowBiometricalAuthentication = initialAllowBiometricalAuthentication,
selectedCake2FAPreset = initialCake2FAPresetOptions, selectedCake2FAPreset = initialCake2FAPresetOptions,
totpSecretKey = initialTotpSecretKey, totpSecretKey = initialTotpSecretKey,
@ -325,9 +323,6 @@ abstract class SettingsStoreBase with Store {
await sharedPreferences.setInt(PreferencesKey.currentTorConnectionModeKey, mode.serialize()); await sharedPreferences.setInt(PreferencesKey.currentTorConnectionModeKey, mode.serialize());
}); });
reaction((_) => shouldStartTorOnLaunch,
(bool value) => sharedPreferences.setBool(PreferencesKey.shouldStartTorOnLaunch, value));
reaction((_) => currentTheme, reaction((_) => currentTheme,
(ThemeBase theme) => sharedPreferences.setInt(PreferencesKey.currentTheme, theme.raw)); (ThemeBase theme) => sharedPreferences.setInt(PreferencesKey.currentTheme, theme.raw));
@ -550,9 +545,6 @@ abstract class SettingsStoreBase with Store {
@observable @observable
TorConnectionMode torConnectionMode; TorConnectionMode torConnectionMode;
@observable
bool shouldStartTorOnLaunch;
@observable @observable
bool shouldSaveRecipientAddress; bool shouldSaveRecipientAddress;
@ -805,8 +797,6 @@ abstract class SettingsStoreBase with Store {
final currentTorConnectionMode = TorConnectionMode.deserialize( final currentTorConnectionMode = TorConnectionMode.deserialize(
raw: sharedPreferences.getInt(PreferencesKey.currentTorConnectionModeKey) ?? raw: sharedPreferences.getInt(PreferencesKey.currentTorConnectionModeKey) ??
TorConnectionMode.disabled.raw); TorConnectionMode.disabled.raw);
final shouldStartTorOnLaunch =
sharedPreferences.getBool(PreferencesKey.shouldStartTorOnLaunch) ?? false;
final tokenTrialNumber = sharedPreferences.getInt(PreferencesKey.failedTotpTokenTrials) ?? 0; final tokenTrialNumber = sharedPreferences.getInt(PreferencesKey.failedTotpTokenTrials) ?? 0;
final shouldShowMarketPlaceInDashboard = final shouldShowMarketPlaceInDashboard =
sharedPreferences.getBool(PreferencesKey.shouldShowMarketPlaceInDashboard) ?? true; sharedPreferences.getBool(PreferencesKey.shouldShowMarketPlaceInDashboard) ?? true;
@ -1049,7 +1039,6 @@ abstract class SettingsStoreBase with Store {
initialWalletListAscending: walletListAscending, initialWalletListAscending: walletListAscending,
initialFiatMode: currentFiatApiMode, initialFiatMode: currentFiatApiMode,
initialTorConnectionMode: currentTorConnectionMode, initialTorConnectionMode: currentTorConnectionMode,
initialShouldStartTorOnLaunch: shouldStartTorOnLaunch,
initialAllowBiometricalAuthentication: allowBiometricalAuthentication, initialAllowBiometricalAuthentication: allowBiometricalAuthentication,
initialCake2FAPresetOptions: selectedCake2FAPreset, initialCake2FAPresetOptions: selectedCake2FAPreset,
initialUseTOTP2FA: useTOTP2FA, initialUseTOTP2FA: useTOTP2FA,

View file

@ -83,9 +83,6 @@ abstract class PrivacySettingsViewModelBase with Store {
@computed @computed
bool get looksUpENS => _settingsStore.lookupsENS; bool get looksUpENS => _settingsStore.lookupsENS;
@computed
bool get shouldStartTorOnLaunch => _settingsStore.shouldStartTorOnLaunch;
bool get canUseEtherscan => _wallet.type == WalletType.ethereum; bool get canUseEtherscan => _wallet.type == WalletType.ethereum;
bool get canUsePolygonScan => _wallet.type == WalletType.polygon; bool get canUsePolygonScan => _wallet.type == WalletType.polygon;
@ -127,9 +124,6 @@ abstract class PrivacySettingsViewModelBase with Store {
@action @action
void setLookupsOpenAlias(bool value) => _settingsStore.lookupsOpenAlias = value; void setLookupsOpenAlias(bool value) => _settingsStore.lookupsOpenAlias = value;
@action
void setShouldStartTorOnLaunch(bool value) => _settingsStore.shouldStartTorOnLaunch = value;
@action @action
void setUseEtherscan(bool value) { void setUseEtherscan(bool value) {
_settingsStore.useEtherscan = value; _settingsStore.useEtherscan = value;

View file

@ -33,11 +33,6 @@ abstract class TorViewModelBase with Store {
final SettingsStore _settingsStore; final SettingsStore _settingsStore;
Tor torInstance = Tor.instance; Tor torInstance = Tor.instance;
@action
Future<void> updateStartOnLaunch(bool value) async {
_settingsStore.shouldStartTorOnLaunch = value;
}
@computed @computed
TorConnectionMode get torConnectionMode => _settingsStore.torConnectionMode; TorConnectionMode get torConnectionMode => _settingsStore.torConnectionMode;
@ -86,8 +81,6 @@ abstract class TorViewModelBase with Store {
await torInstance.enable(); await torInstance.enable();
_settingsStore.shouldStartTorOnLaunch = true;
SocksTCPClient.setProxy(proxies: [ SocksTCPClient.setProxy(proxies: [
ProxySettings( ProxySettings(
InternetAddress.loopbackIPv4, InternetAddress.loopbackIPv4,
@ -108,8 +101,6 @@ abstract class TorViewModelBase with Store {
@action @action
Future<void> stopTor() async { Future<void> stopTor() async {
torInstance.disable(); torInstance.disable();
// setting the torConnectionMode to disabled will prevent anything from actually using the proxy
_settingsStore.shouldStartTorOnLaunch = false;
torConnectionStatus = TorConnectionStatus.disconnected; torConnectionStatus = TorConnectionStatus.disconnected;
SocksTCPClient.removeProxy(); SocksTCPClient.removeProxy();
await connectOrDisconnectNodeToProxy(connect: false); await connectOrDisconnectNodeToProxy(connect: false);