2023-02-28 16:23:21 +00:00
|
|
|
import 'package:cake_wallet/entities/fiat_api_mode.dart';
|
2024-01-03 18:21:34 +00:00
|
|
|
import 'package:cake_wallet/view_model/settings/tor_connection.dart';
|
2023-02-28 16:23:21 +00:00
|
|
|
import 'package:mobx/mobx.dart';
|
|
|
|
import 'package:cake_wallet/core/fiat_conversion_service.dart';
|
|
|
|
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
|
|
|
import 'package:cake_wallet/store/settings_store.dart';
|
|
|
|
import 'package:cake_wallet/store/app_store.dart';
|
|
|
|
|
|
|
|
ReactionDisposer? _onCurrentFiatCurrencyChangeDisposer;
|
|
|
|
|
2024-01-03 18:21:34 +00:00
|
|
|
void startCurrentFiatApiModeChangeReaction(
|
|
|
|
AppStore appStore, SettingsStore settingsStore, FiatConversionStore fiatConversionStore) {
|
2023-02-28 16:23:21 +00:00
|
|
|
_onCurrentFiatCurrencyChangeDisposer?.reaction.dispose();
|
2024-01-03 18:21:34 +00:00
|
|
|
_onCurrentFiatCurrencyChangeDisposer =
|
|
|
|
reaction((_) => settingsStore.fiatApiMode, (FiatApiMode fiatApiMode) async {
|
2023-02-28 16:23:21 +00:00
|
|
|
if (appStore.wallet == null || fiatApiMode == FiatApiMode.disabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-01-03 18:21:34 +00:00
|
|
|
fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice(
|
|
|
|
crypto: appStore.wallet!.currency,
|
|
|
|
fiat: settingsStore.fiatCurrency,
|
|
|
|
);
|
2023-02-28 16:23:21 +00:00
|
|
|
});
|
|
|
|
}
|