From 899e999d78d366b86cbc528c5f0f2f3df0fc2840 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Fri, 9 Dec 2022 20:04:44 +0200 Subject: [PATCH] check nullability of wallet and disable fiat api state before updating rates [skip ci] --- lib/reactions/fiat_rate_update.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/reactions/fiat_rate_update.dart b/lib/reactions/fiat_rate_update.dart index 04276b567..48c61d8ca 100644 --- a/lib/reactions/fiat_rate_update.dart +++ b/lib/reactions/fiat_rate_update.dart @@ -17,13 +17,16 @@ Future startFiatRateUpdate( _timer = Timer.periodic(Duration(seconds: 30), (_) async { try { + if (appStore.wallet == null || settingsStore.fiatApiMode == FiatApiMode.disabled) { + return; + } + if (appStore.wallet!.type == WalletType.haven) { await updateHavenRate(fiatConversionStore); } else { - if (appStore.wallet != null && settingsStore.fiatApiMode == FiatApiMode.enabled) { - fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice( - appStore.wallet!.currency, settingsStore.fiatCurrency); - } + fiatConversionStore.prices[appStore.wallet!.currency] = + await FiatConversionService.fetchPrice( + appStore.wallet!.currency, settingsStore.fiatCurrency); } } catch (e) { print(e);