check nullability of wallet and disable fiat api state before updating rates [skip ci]

This commit is contained in:
OmarHatem 2022-12-09 20:04:44 +02:00
parent fde1ea74de
commit 899e999d78

View file

@ -17,13 +17,16 @@ Future<void> startFiatRateUpdate(
_timer = Timer.periodic(Duration(seconds: 30), (_) async { _timer = Timer.periodic(Duration(seconds: 30), (_) async {
try { try {
if (appStore.wallet == null || settingsStore.fiatApiMode == FiatApiMode.disabled) {
return;
}
if (appStore.wallet!.type == WalletType.haven) { if (appStore.wallet!.type == WalletType.haven) {
await updateHavenRate(fiatConversionStore); await updateHavenRate(fiatConversionStore);
} else { } else {
if (appStore.wallet != null && settingsStore.fiatApiMode == FiatApiMode.enabled) { fiatConversionStore.prices[appStore.wallet!.currency] =
fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice( await FiatConversionService.fetchPrice(
appStore.wallet!.currency, settingsStore.fiatCurrency); appStore.wallet!.currency, settingsStore.fiatCurrency);
}
} }
} catch (e) { } catch (e) {
print(e); print(e);