check nullability of wallet and disable fiat api state before updating rates [skip ci]
OmarHatem committed
Dec 9, 2022 at 20:04 UTC
899e999d78d366b86cbc528c5f0f2f3df0fc2840
1 file changed
+7
-4
lib/reactions/fiat_rate_update.dart
+7
-4
@@ -17,13 +17,16 @@ Future<void> startFiatRateUpdate(
17
18
_timer = Timer.periodic(Duration(seconds: 30), (_) async {
19
try {
20
+ if (appStore.wallet == null || settingsStore.fiatApiMode == FiatApiMode.disabled) {
21
+ return;
22
+ }
23
+
24
if (appStore.wallet!.type == WalletType.haven) {
25
await updateHavenRate(fiatConversionStore);
26
} else {
23
- if (appStore.wallet != null && settingsStore.fiatApiMode == FiatApiMode.enabled) {
24
- fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice(
25
- appStore.wallet!.currency, settingsStore.fiatCurrency);
26
- }
27
+ fiatConversionStore.prices[appStore.wallet!.currency] =
28
+ await FiatConversionService.fetchPrice(
29
+ appStore.wallet!.currency, settingsStore.fiatCurrency);
30
}
31
} catch (e) {
32
print(e);