Check for Nodes if exists before adding them in nodes Fix nullability issue due to early access Fix Nodes_list,yml file structure

Check for Nodes if exists before adding them in nodes Fix nullability issue due to early access Fix Nodes_list,yml file structure

OmarHatem committed Nov 26, 2022 at 16:13 UTC 79fb1b91d4b661cba9e1e668f59c9fcf152dc76b
3 files changed +22 -8
assets/node_list.yml
+2 -2
@@ -22,10 +22,10 @@
22 -
23 uri: node.imonero.org:18081
24 is_default: false
25 -
25 +-
26 uri: node.c3pool.com:18081
27 is_default: false
28 -
28 +-
29 uri: xmr.prprpr.icu:18081
30 is_default: false
31
lib/entities/default_settings_migration.dart
+18 -4
@@ -69,6 +69,8 @@ Future defaultSettingsMigration(
69 sharedPreferences: sharedPreferences, nodes: nodes);
70 await changeLitecoinCurrentElectrumServerToDefault(
71 sharedPreferences: sharedPreferences, nodes: nodes);
72 + await changeHavenCurrentNodeToDefault(
73 + sharedPreferences: sharedPreferences, nodes: nodes);
74
75 break;
76 case 2:
@@ -277,17 +279,29 @@ Future<void> updateNodeTypes({required Box<Node> nodes}) async {
279
280 Future<void> addBitcoinElectrumServerList({required Box<Node> nodes}) async {
281 final serverList = await loadBitcoinElectrumServerList();
280 - await nodes.addAll(serverList);
282 + for (var node in serverList) {
283 + if (nodes.values.firstWhereOrNull((element) => element.uriRaw == node.uriRaw) == null) {
284 + await nodes.add(node);
285 + }
286 + }
287 }
288
289 Future<void> addLitecoinElectrumServerList({required Box<Node> nodes}) async {
290 final serverList = await loadLitecoinElectrumServerList();
285 - await nodes.addAll(serverList);
291 + for (var node in serverList) {
292 + if (nodes.values.firstWhereOrNull((element) => element.uriRaw == node.uriRaw) == null) {
293 + await nodes.add(node);
294 + }
295 + }
296 }
297
298 Future<void> addHavenNodeList({required Box<Node> nodes}) async {
299 final nodeList = await loadDefaultHavenNodes();
290 - await nodes.addAll(nodeList);
300 + for (var node in nodeList) {
301 + if (nodes.values.firstWhereOrNull((element) => element.uriRaw == node.uriRaw) == null) {
302 + await nodes.add(node);
303 + }
304 + }
305 }
306
307 Future<void> addAddressesForMoneroWallets(
@@ -431,7 +445,7 @@ Future<void> resetBitcoinElectrumServer(
445 final oldElectrumServer = nodeSource.values.firstWhereOrNull(
446 (node) => node.uri.toString().contains('electrumx.cakewallet.com'));
447 var cakeWalletNode = nodeSource.values.firstWhereOrNull(
434 - (node) => node.uri.toString() == cakeWalletBitcoinElectrumUri);
448 + (node) => node.uriRaw.toString() == cakeWalletBitcoinElectrumUri);
449
450 if (cakeWalletNode == null) {
451 cakeWalletNode =
lib/reactions/on_authentication_state_change.dart
+2 -2
@@ -23,12 +23,12 @@ void startAuthenticationStateChange(AuthenticationStore authenticationStore,
23 }
24
25 if (state == AuthenticationState.allowed) {
26 - await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
26 + await navigatorKey.currentState?.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
27 return;
28 }
29
30 if (state == AuthenticationState.denied) {
31 - await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.welcome, (_) => false);
31 + await navigatorKey.currentState?.pushNamedAndRemoveUntil(Routes.welcome, (_) => false);
32 return;
33 }
34 });