mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
Merge pull request #853 from cake-tech/CW-339-Advanced-settings-page-crash-on-a-fresh-install
CW-339-Advanced-settings-page-crash-on-a-fresh-install
This commit is contained in:
commit
9f1325ba0f
3 changed files with 14 additions and 13 deletions
|
@ -560,8 +560,7 @@ Future setup(
|
|||
(WalletType? type, _) => NodeCreateOrEditViewModel(
|
||||
_nodeSource,
|
||||
type ?? getIt.get<AppStore>().wallet!.type,
|
||||
getIt.get<SettingsStore>(),
|
||||
getIt.get<NodeListViewModel>()
|
||||
getIt.get<SettingsStore>()
|
||||
));
|
||||
|
||||
getIt.registerFactoryParam<NodeCreateOrEditPage, Node?, bool?>(
|
||||
|
|
|
@ -22,8 +22,8 @@ class NodeForm extends StatelessWidget {
|
|||
nodeViewModel
|
||||
..setAddress((editingNode!.uri.host.toString()))
|
||||
..setPort((editingNode!.uri.port.toString()))
|
||||
..setPassword((editingNode!.password.toString()))
|
||||
..setLogin((editingNode!.login.toString()))
|
||||
..setPassword((editingNode!.password ?? ''))
|
||||
..setLogin((editingNode!.login ?? ''))
|
||||
..setSSL((editingNode!.isSSL))
|
||||
..setTrusted((editingNode!.trusted));
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@ class NodeCreateOrEditViewModel = NodeCreateOrEditViewModelBase
|
|||
with _$NodeCreateOrEditViewModel;
|
||||
|
||||
abstract class NodeCreateOrEditViewModelBase with Store {
|
||||
NodeCreateOrEditViewModelBase(this._nodeSource, this._walletType, this._settingsStore,
|
||||
this.nodeListViewModel)
|
||||
NodeCreateOrEditViewModelBase(this._nodeSource, this._walletType, this._settingsStore)
|
||||
: state = InitialExecutionState(),
|
||||
connectionState = InitialExecutionState(),
|
||||
useSSL = false,
|
||||
|
@ -68,7 +67,6 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
|||
final WalletType _walletType;
|
||||
final Box<Node> _nodeSource;
|
||||
final SettingsStore _settingsStore;
|
||||
final NodeListViewModel nodeListViewModel;
|
||||
|
||||
@action
|
||||
void reset() {
|
||||
|
@ -100,16 +98,20 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
|||
|
||||
@action
|
||||
Future<void> save({Node? editingNode, bool saveAsCurrent = false}) async {
|
||||
final node = Node(
|
||||
uri: uri,
|
||||
type: _walletType,
|
||||
login: login,
|
||||
password: password,
|
||||
useSSL: useSSL,
|
||||
trusted: trusted);
|
||||
try {
|
||||
state = IsExecutingState();
|
||||
if (editingNode != null) {
|
||||
await nodeListViewModel.delete(editingNode);
|
||||
await _nodeSource.put(editingNode.key, node);
|
||||
} else {
|
||||
await _nodeSource.add(node);
|
||||
}
|
||||
final node =
|
||||
Node(uri: uri, type: _walletType, login: login, password: password,
|
||||
useSSL: useSSL, trusted: trusted);
|
||||
await _nodeSource.add(node);
|
||||
|
||||
if (saveAsCurrent) {
|
||||
_settingsStore.nodes[_walletType] = node;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue