mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
* auto-select custom node on wallet creation * safeguard for wallet type
28 lines
826 B
Dart
28 lines
826 B
Dart
import 'package:cw_core/utils/print_verbose.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:cake_wallet/store/app_store.dart';
|
|
|
|
ReactionDisposer? _onCurrentNodeChangeReaction;
|
|
|
|
void startOnCurrentNodeChangeReaction(AppStore appStore) {
|
|
_onCurrentNodeChangeReaction?.reaction.dispose();
|
|
appStore.settingsStore.nodes.observe((change) async {
|
|
try {
|
|
if(change.newValue?.type == appStore.wallet!.type) {
|
|
await appStore.wallet!.connectToNode(node: change.newValue!);
|
|
}
|
|
} catch (e) {
|
|
printV(e.toString());
|
|
}
|
|
});
|
|
appStore.settingsStore.powNodes.observe((change) async {
|
|
try {
|
|
if(change.newValue?.type == appStore.wallet!.type) {
|
|
await appStore.wallet!.connectToPowNode(node: change.newValue!);
|
|
}
|
|
} catch (e) {
|
|
printV(e.toString());
|
|
}
|
|
});
|
|
}
|