feat: disable automatic node switching (#2807)

This commit is contained in:
David Adegoke
2026-01-15 14:43:00 +01:00
committed by GitHub
parent de33666b75
commit 9bac419cb7
4 changed files with 28 additions and 18 deletions
+5 -1
View File
@@ -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<void> performHealthCheck() async {
if (appStore.wallet == null) return;
if (!settingsStore.enableAutomaticNodeSwitching) return;
if (!FeatureFlag.isAutomaticNodeSwitchingEnabled ||
!settingsStore.enableAutomaticNodeSwitching) {
return;
}
if (_isSwitching) return;
+4 -1
View File
@@ -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<void> bootstrapOffline() async {
final authenticationStore = getIt.get<AuthenticationStore>();
@@ -42,5 +43,7 @@ void bootstrapOnline(GlobalKey<NavigatorState> navigatorKey, {required bool load
startOnCurrentNodeChangeReaction(appStore);
startFiatRateUpdate(appStore, settingsStore, fiatConversionStore);
getIt.get<NodeSwitchingService>().startHealthCheckTimer();
if (FeatureFlag.isAutomaticNodeSwitchingEnabled) {
getIt.get<NodeSwitchingService>().startHealthCheckTimer();
}
}
+18 -16
View File
@@ -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 =
+1
View File
@@ -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;
}