mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
Remove SecretStore class for Backup viewmodels (fix for backup password not restoring) (#2723)
* backup page viewmodels without secretstore class * minor reaction optimization * minor reaction optimization
This commit is contained in:
@@ -4,7 +4,7 @@ import 'package:cake_wallet/core/backup_service_v3.dart';
|
||||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:cake_wallet/core/secure_storage.dart';
|
||||
import 'package:cake_wallet/entities/secret_store_key.dart';
|
||||
import 'package:cake_wallet/store/secret_store.dart';
|
||||
import 'package:cake_wallet/view_model/edit_backup_password_view_model.dart';
|
||||
import 'package:cw_core/root_dir.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -25,21 +25,28 @@ class BackupExportFile {
|
||||
class BackupViewModel = BackupViewModelBase with _$BackupViewModel;
|
||||
|
||||
abstract class BackupViewModelBase with Store {
|
||||
BackupViewModelBase(this.secureStorage, this.secretStore, this.backupService)
|
||||
BackupViewModelBase(this.secureStorage, this.backupService, this.editBackupPasswordViewModel)
|
||||
: isBackupPasswordVisible = false,
|
||||
backupPassword = '',
|
||||
state = InitialExecutionState() {
|
||||
final key = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
||||
secretStore.values.observe((change) {
|
||||
if (change.key == key) {
|
||||
backupPassword = secretStore.read(key);
|
||||
init();
|
||||
|
||||
reaction((_) => editBackupPasswordViewModel.backupPassword, (value) {
|
||||
if(value != backupPassword) {
|
||||
backupPassword = value;
|
||||
}
|
||||
}, fireImmediately: true);
|
||||
});
|
||||
|
||||
reaction((_)=>backupPassword, (value){
|
||||
if(value != editBackupPasswordViewModel.backupPassword) {
|
||||
editBackupPasswordViewModel.backupPassword = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final SecureStorage secureStorage;
|
||||
final SecretStore secretStore;
|
||||
final BackupServiceV3 backupService;
|
||||
final EditBackupPasswordViewModel editBackupPasswordViewModel;
|
||||
|
||||
@observable
|
||||
ExecutionState state;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:cake_wallet/core/secure_storage.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/entities/secret_store_key.dart';
|
||||
import 'package:cake_wallet/store/secret_store.dart';
|
||||
|
||||
part 'edit_backup_password_view_model.g.dart';
|
||||
|
||||
@@ -9,12 +8,11 @@ class EditBackupPasswordViewModel = EditBackupPasswordViewModelBase
|
||||
with _$EditBackupPasswordViewModel;
|
||||
|
||||
abstract class EditBackupPasswordViewModelBase with Store {
|
||||
EditBackupPasswordViewModelBase(this.secureStorage, this.secretStore)
|
||||
: backupPassword = secretStore.read(generateStoreKeyFor(key: SecretStoreKey.backupPassword)),
|
||||
_originalPassword = '';
|
||||
EditBackupPasswordViewModelBase(this.secureStorage,)
|
||||
: backupPassword = "",
|
||||
_originalPassword = ''{init();}
|
||||
|
||||
final SecureStorage secureStorage;
|
||||
final SecretStore secretStore;
|
||||
|
||||
@observable
|
||||
String backupPassword;
|
||||
@@ -38,6 +36,5 @@ abstract class EditBackupPasswordViewModelBase with Store {
|
||||
Future<void> save() async {
|
||||
final key = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
||||
await secureStorage.write(key: key, value: backupPassword);
|
||||
secretStore.write(key: key, value: backupPassword);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user