From 9bac419cb7d7f57c9c197786898a93d87948b108 Mon Sep 17 00:00:00 2001 From: David Adegoke <64401859+Blazebrain@users.noreply.github.com> Date: Thu, 15 Jan 2026 14:43:00 +0100 Subject: [PATCH] feat: disable automatic node switching (#2807) --- lib/core/node_switching_service.dart | 6 +++- lib/reactions/bootstrap.dart | 5 ++- .../screens/settings/manage_nodes_page.dart | 34 ++++++++++--------- lib/utils/feature_flag.dart | 1 + 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/lib/core/node_switching_service.dart b/lib/core/node_switching_service.dart index 8c82cdded..6f7b36dc3 100644 --- a/lib/core/node_switching_service.dart +++ b/lib/core/node_switching_service.dart @@ -3,6 +3,7 @@ import 'package:cw_core/node.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:cake_wallet/store/app_store.dart'; import 'package:cake_wallet/store/settings_store.dart'; +import 'package:cake_wallet/utils/feature_flag.dart'; import 'package:cw_core/utils/print_verbose.dart'; import 'package:hive/hive.dart'; import 'package:connectivity_plus/connectivity_plus.dart'; @@ -57,7 +58,10 @@ class NodeSwitchingService { Future performHealthCheck() async { if (appStore.wallet == null) return; - if (!settingsStore.enableAutomaticNodeSwitching) return; + if (!FeatureFlag.isAutomaticNodeSwitchingEnabled || + !settingsStore.enableAutomaticNodeSwitching) { + return; + } if (_isSwitching) return; diff --git a/lib/reactions/bootstrap.dart b/lib/reactions/bootstrap.dart index 5f16c5b54..8cbf402dd 100644 --- a/lib/reactions/bootstrap.dart +++ b/lib/reactions/bootstrap.dart @@ -15,6 +15,7 @@ import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/store/authentication_store.dart'; import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart'; import 'package:cake_wallet/core/node_switching_service.dart'; +import 'package:cake_wallet/utils/feature_flag.dart'; Future bootstrapOffline() async { final authenticationStore = getIt.get(); @@ -42,5 +43,7 @@ void bootstrapOnline(GlobalKey navigatorKey, {required bool load startOnCurrentNodeChangeReaction(appStore); startFiatRateUpdate(appStore, settingsStore, fiatConversionStore); - getIt.get().startHealthCheckTimer(); + if (FeatureFlag.isAutomaticNodeSwitchingEnabled) { + getIt.get().startHealthCheckTimer(); + } } \ No newline at end of file diff --git a/lib/src/screens/settings/manage_nodes_page.dart b/lib/src/screens/settings/manage_nodes_page.dart index 92d1d5e76..42313daaf 100644 --- a/lib/src/screens/settings/manage_nodes_page.dart +++ b/lib/src/screens/settings/manage_nodes_page.dart @@ -5,6 +5,7 @@ import 'package:cake_wallet/src/screens/nodes/widgets/node_list_row.dart'; import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/src/widgets/standard_list.dart'; +import 'package:cake_wallet/utils/feature_flag.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/node_list/node_list_view_model.dart'; import 'package:cake_wallet/view_model/node_list/pow_node_list_view_model.dart'; @@ -35,23 +36,24 @@ class ManageNodesPage extends BasePage { onTap: (_) async => await Navigator.of(context).pushNamed(Routes.newNode), ), ), - Observer( - builder: (_) => SettingsSwitcherCell( - key: ValueKey('manage_nodes_page_enable_auto_node_switching_button_key'), - title: S.current.enable_auto_node_switching, - value: isPow - ? powNodeListViewModel!.enableAutomaticNodeSwitching - : nodeListViewModel!.enableAutomaticNodeSwitching, - onValueChange: (BuildContext context, bool value) { - if (isPow) { - powNodeListViewModel!.setEnableAutomaticNodeSwitching(value); - } else { - nodeListViewModel!.setEnableAutomaticNodeSwitching(value); - } - }, + if (FeatureFlag.isAutomaticNodeSwitchingEnabled) + Observer( + builder: (_) => SettingsSwitcherCell( + key: ValueKey('manage_nodes_page_enable_auto_node_switching_button_key'), + title: S.current.enable_auto_node_switching, + value: isPow + ? powNodeListViewModel!.enableAutomaticNodeSwitching + : nodeListViewModel!.enableAutomaticNodeSwitching, + onValueChange: (BuildContext context, bool value) { + if (isPow) { + powNodeListViewModel!.setEnableAutomaticNodeSwitching(value); + } else { + nodeListViewModel!.setEnableAutomaticNodeSwitching(value); + } + }, + ), ), - ), - SizedBox(height: 8), + if (FeatureFlag.isAutomaticNodeSwitchingEnabled) SizedBox(height: 8), Observer( builder: (BuildContext context) { int itemsCount = diff --git a/lib/utils/feature_flag.dart b/lib/utils/feature_flag.dart index 1a3062c25..ee58ed197 100644 --- a/lib/utils/feature_flag.dart +++ b/lib/utils/feature_flag.dart @@ -14,4 +14,5 @@ class FeatureFlag { static const bool hasBitcoinViewOnly = true; static const bool customBackgroundEnabled = false; static const bool duressPinEnabled = true; + static const bool isAutomaticNodeSwitchingEnabled = false; }