mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 01:37:40 +00:00
- Fix reloading settings store
- Revert changes to backup_service.dart
This commit is contained in:
parent
d961a4645e
commit
c235df8935
4 changed files with 31 additions and 53 deletions
|
@ -1,7 +1,6 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
@ -21,7 +20,7 @@ import 'package:cake_backup/backup.dart' as cake_backup;
|
|||
|
||||
class BackupService {
|
||||
BackupService(this._flutterSecureStorage, this._walletInfoSource,
|
||||
this._keyService, this._sharedPreferences, this._settingsStore)
|
||||
this._keyService, this._sharedPreferences)
|
||||
: _cipher = Cryptography.instance.chacha20Poly1305Aead(),
|
||||
_correctWallets = <WalletInfo>[];
|
||||
|
||||
|
@ -34,7 +33,6 @@ class BackupService {
|
|||
final FlutterSecureStorage _flutterSecureStorage;
|
||||
final SharedPreferences _sharedPreferences;
|
||||
final Box<WalletInfo> _walletInfoSource;
|
||||
final SettingsStore _settingsStore;
|
||||
final KeyService _keyService;
|
||||
List<WalletInfo> _correctWallets;
|
||||
|
||||
|
@ -303,7 +301,6 @@ class BackupService {
|
|||
as Map<String, dynamic>;
|
||||
final keychainWalletsInfo = keychainJSON['wallets'] as List;
|
||||
final decodedPin = keychainJSON['pin'] as String;
|
||||
_settingsStore.pinCodeLength = decodedPin.length;
|
||||
final pinCodeKey = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
||||
final backupPasswordKey =
|
||||
generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
||||
|
@ -334,7 +331,6 @@ class BackupService {
|
|||
final keychainWalletsInfo = keychainJSON['wallets'] as List;
|
||||
final decodedPin = keychainJSON['pin'] as String;
|
||||
final pinCodeKey = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
||||
_settingsStore.pinCodeLength = decodedPin.length;
|
||||
final backupPasswordKey =
|
||||
generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
||||
final backupPassword = keychainJSON[backupPasswordKey] as String;
|
||||
|
|
|
@ -606,9 +606,7 @@ Future setup(
|
|||
getIt.get<FlutterSecureStorage>(),
|
||||
_walletInfoSource,
|
||||
getIt.get<KeyService>(),
|
||||
getIt.get<SharedPreferences>(),
|
||||
getIt.get<SettingsStore>(),
|
||||
));
|
||||
getIt.get<SharedPreferences>()));
|
||||
|
||||
getIt.registerFactory(() => BackupViewModel(getIt.get<FlutterSecureStorage>(),
|
||||
getIt.get<SecretStore>(), getIt.get<BackupService>()));
|
||||
|
|
|
@ -3,7 +3,6 @@ import 'package:cake_wallet/entities/preferences_key.dart';
|
|||
import 'package:cw_core/transaction_priority.dart';
|
||||
import 'package:cake_wallet/themes/theme_base.dart';
|
||||
import 'package:cake_wallet/themes/theme_list.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
@ -234,8 +233,7 @@ abstract class SettingsStoreBase with Store {
|
|||
: ThemeType.bright.index;
|
||||
final savedTheme = ThemeList.deserialize(
|
||||
raw: sharedPreferences.getInt(PreferencesKey.currentTheme) ??
|
||||
legacyTheme ??
|
||||
0);
|
||||
legacyTheme);
|
||||
final actionListDisplayMode = ObservableList<ActionListDisplayMode>();
|
||||
actionListDisplayMode.addAll(deserializeActionlistDisplayModes(
|
||||
sharedPreferences.getInt(PreferencesKey.displayActionListModeKey) ??
|
||||
|
@ -281,7 +279,7 @@ abstract class SettingsStoreBase with Store {
|
|||
if (havenNode != null) {
|
||||
nodes[WalletType.haven] = havenNode;
|
||||
}
|
||||
|
||||
|
||||
return SettingsStore(
|
||||
sharedPreferences: sharedPreferences,
|
||||
nodes: nodes,
|
||||
|
@ -301,48 +299,35 @@ abstract class SettingsStoreBase with Store {
|
|||
shouldShowYatPopup: shouldShowYatPopup);
|
||||
}
|
||||
|
||||
// FIX-ME: Dead code
|
||||
Future<void> reload(
|
||||
{required Box<Node> nodeSource,
|
||||
FiatCurrency initialFiatCurrency = FiatCurrency.usd,
|
||||
TransactionPriority? initialMoneroTransactionPriority,
|
||||
TransactionPriority? initialBitcoinTransactionPriority,
|
||||
BalanceDisplayMode initialBalanceDisplayMode = BalanceDisplayMode.availableBalance}) async {
|
||||
if (initialBitcoinTransactionPriority == null) {
|
||||
initialBitcoinTransactionPriority = bitcoin?.getMediumTransactionPriority();
|
||||
}
|
||||
|
||||
//Future<void> reload(
|
||||
// {required Box<Node> nodeSource,
|
||||
// FiatCurrency initialFiatCurrency = FiatCurrency.usd,
|
||||
// TransactionPriority? initialMoneroTransactionPriority,
|
||||
// TransactionPriority? initialBitcoinTransactionPriority,
|
||||
// BalanceDisplayMode initialBalanceDisplayMode =
|
||||
// BalanceDisplayMode.availableBalance}) async {
|
||||
|
||||
// if (initialBitcoinTransactionPriority == null) {
|
||||
// initialBitcoinTransactionPriority = bitcoin?.getMediumTransactionPriority();
|
||||
// }
|
||||
if (initialMoneroTransactionPriority == null) {
|
||||
initialMoneroTransactionPriority = monero?.getDefaultTransactionPriority();
|
||||
}
|
||||
|
||||
// if (initialMoneroTransactionPriority == null) {
|
||||
// initialMoneroTransactionPriority = monero?.getDefaultTransactionPriority();
|
||||
// }
|
||||
final isBitcoinBuyEnabled = (secrets.wyreSecretKey.isNotEmpty) &&
|
||||
(secrets.wyreApiKey.isNotEmpty) &&
|
||||
(secrets.wyreAccountId.isNotEmpty);
|
||||
|
||||
// final isBitcoinBuyEnabled = (secrets.wyreSecretKey?.isNotEmpty ?? false) &&
|
||||
// (secrets.wyreApiKey?.isNotEmpty ?? false) &&
|
||||
// (secrets.wyreAccountId?.isNotEmpty ?? false);
|
||||
final settings = await SettingsStoreBase.load(
|
||||
nodeSource: nodeSource,
|
||||
isBitcoinBuyEnabled: isBitcoinBuyEnabled,
|
||||
initialBalanceDisplayMode: initialBalanceDisplayMode,
|
||||
initialFiatCurrency: initialFiatCurrency,
|
||||
initialMoneroTransactionPriority: initialMoneroTransactionPriority,
|
||||
initialBitcoinTransactionPriority: initialBitcoinTransactionPriority);
|
||||
|
||||
// final settings = await SettingsStoreBase.load(
|
||||
// nodeSource: nodeSource,
|
||||
// isBitcoinBuyEnabled: isBitcoinBuyEnabled,
|
||||
// initialBalanceDisplayMode: initialBalanceDisplayMode,
|
||||
// initialFiatCurrency: initialFiatCurrency,
|
||||
// initialMoneroTransactionPriority: initialMoneroTransactionPriority,
|
||||
// initialBitcoinTransactionPriority: initialBitcoinTransactionPriority);
|
||||
// fiatCurrency = settings.fiatCurrency;
|
||||
// actionlistDisplayMode = settings.actionlistDisplayMode;
|
||||
// priority[WalletType.monero] = initialMoneroTransactionPriority;
|
||||
// priority[WalletType.bitcoin] = initialBitcoinTransactionPriority;
|
||||
// balanceDisplayMode = settings.balanceDisplayMode;
|
||||
// shouldSaveRecipientAddress = settings.shouldSaveRecipientAddress;
|
||||
// allowBiometricalAuthentication = settings.allowBiometricalAuthentication;
|
||||
// currentTheme = settings.currentTheme;
|
||||
// pinCodeLength = settings.pinCodeLength;
|
||||
// languageCode = settings.languageCode;
|
||||
// appVersion = settings.appVersion;
|
||||
// shouldShowYatPopup = settings.shouldShowYatPopup;
|
||||
//}
|
||||
getIt.unregister<SettingsStore>();
|
||||
getIt.registerSingleton<SettingsStore>(settings);
|
||||
}
|
||||
|
||||
Future<void> _saveCurrentNode(Node node, WalletType walletType) async {
|
||||
switch (walletType) {
|
||||
|
|
|
@ -35,7 +35,7 @@ abstract class RestoreFromBackupViewModelBase with Store {
|
|||
try {
|
||||
state = IsExecutingState();
|
||||
|
||||
if (filePath?.isEmpty ?? true) {
|
||||
if (filePath.isEmpty) {
|
||||
state = FailureState('Backup file is not selected.');
|
||||
return;
|
||||
}
|
||||
|
@ -48,8 +48,7 @@ abstract class RestoreFromBackupViewModelBase with Store {
|
|||
|
||||
final store = getIt.get<AppStore>();
|
||||
ReactionDisposer? reaction;
|
||||
// FIX-ME: SettingsStore reload
|
||||
// await store.settingsStore.reload(nodeSource: getIt.get<Box<Node>>());
|
||||
await store.settingsStore.reload(nodeSource: getIt.get<Box<Node>>());
|
||||
|
||||
reaction = autorun((_) {
|
||||
final wallet = store.wallet;
|
||||
|
|
Loading…
Reference in a new issue