disable service status api if fiat api is disabled (#1357)
Matthew Fosse committed
Apr 2, 2024 at 11:02 UTC
7eed97718e6f1d037b7f21787d2e8cd59fad2a95
2 files changed
+34
-16
lib/entities/default_settings_migration.dart
+17
@@ -1,6 +1,7 @@
1
import 'dart:io' show Directory, File, Platform;
2
import 'package:cake_wallet/bitcoin/bitcoin.dart';
3
import 'package:cake_wallet/entities/exchange_api_mode.dart';
4
+import 'package:cake_wallet/entities/fiat_api_mode.dart';
5
import 'package:cw_core/pathForWallet.dart';
6
import 'package:cake_wallet/entities/secret_store_key.dart';
7
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
@@ -211,6 +212,10 @@ Future<void> defaultSettingsMigration(
212
await changeDefaultBitcoinNode(nodes, sharedPreferences);
213
break;
214
215
+ case 30:
216
+ await disableServiceStatusFiatDisabled(sharedPreferences);
217
+ break;
218
+
219
default:
220
break;
221
}
@@ -225,6 +230,18 @@ Future<void> defaultSettingsMigration(
230
await sharedPreferences.setInt(PreferencesKey.currentDefaultSettingsMigrationVersion, version);
231
}
232
233
+Future<void> disableServiceStatusFiatDisabled(SharedPreferences sharedPreferences) async {
234
+ final currentFiat =
235
+ await sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey) ?? -1;
236
+ if (currentFiat == -1 || currentFiat == FiatApiMode.enabled.raw) {
237
+ return;
238
+ }
239
+
240
+ if (currentFiat == FiatApiMode.disabled.raw) {
241
+ await sharedPreferences.setBool(PreferencesKey.disableBulletinKey, true);
242
+ }
243
+}
244
+
245
Future<void> _updateMoneroPriority(SharedPreferences sharedPreferences) async {
246
final currentPriority =
247
await sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority) ??
lib/main.dart
+17
-16
@@ -149,25 +149,26 @@ Future<void> initializeAppConfigs() async {
149
final unspentCoinsInfoSource = await CakeHive.openBox<UnspentCoinsInfo>(UnspentCoinsInfo.boxName);
150
151
await initialSetup(
152
- sharedPreferences: await SharedPreferences.getInstance(),
153
- nodes: nodes,
154
- powNodes: powNodes,
155
- walletInfoSource: walletInfoSource,
156
- contactSource: contacts,
157
- tradesSource: trades,
158
- ordersSource: orders,
159
- unspentCoinsInfoSource: unspentCoinsInfoSource,
160
- // fiatConvertationService: fiatConvertationService,
161
- templates: templates,
162
- exchangeTemplates: exchangeTemplates,
163
- transactionDescriptions: transactionDescriptions,
164
- secureStorage: secureStorage,
165
- anonpayInvoiceInfo: anonpayInvoiceInfo,
166
- initialMigrationVersion: 29);
152
+ sharedPreferences: await SharedPreferences.getInstance(),
153
+ nodes: nodes,
154
+ powNodes: powNodes,
155
+ walletInfoSource: walletInfoSource,
156
+ contactSource: contacts,
157
+ tradesSource: trades,
158
+ ordersSource: orders,
159
+ unspentCoinsInfoSource: unspentCoinsInfoSource,
160
+ // fiatConvertationService: fiatConvertationService,
161
+ templates: templates,
162
+ exchangeTemplates: exchangeTemplates,
163
+ transactionDescriptions: transactionDescriptions,
164
+ secureStorage: secureStorage,
165
+ anonpayInvoiceInfo: anonpayInvoiceInfo,
166
+ initialMigrationVersion: 30,
167
+ );
168
}
169
170
Future<void> initialSetup(
170
- {required SharedPreferences sharedPreferences,
171
+ {required SharedPreferences sharedPreferences,
172
required Box<Node> nodes,
173
required Box<Node> powNodes,
174
required Box<WalletInfo> walletInfoSource,