2020-09-21 11:50:26 +00:00
|
|
|
import 'package:mobx/mobx.dart';
|
2020-10-30 13:56:23 +00:00
|
|
|
import 'package:cake_wallet/core/fiat_conversion_service.dart';
|
|
|
|
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/store/settings_store.dart';
|
|
|
|
import 'package:cake_wallet/store/app_store.dart';
|
|
|
|
import 'package:cake_wallet/entities/fiat_currency.dart';
|
|
|
|
|
|
|
|
ReactionDisposer _onCurrentFiatCurrencyChangeDisposer;
|
|
|
|
|
2020-12-15 16:29:10 +00:00
|
|
|
void startCurrentFiatChangeReaction(AppStore appStore,
|
|
|
|
SettingsStore settingsStore, FiatConversionStore fiatConversionStore) {
|
2020-09-21 11:50:26 +00:00
|
|
|
_onCurrentFiatCurrencyChangeDisposer?.reaction?.dispose();
|
|
|
|
_onCurrentFiatCurrencyChangeDisposer = reaction(
|
2020-12-15 16:29:10 +00:00
|
|
|
(_) => settingsStore.fiatCurrency, (FiatCurrency fiatCurrency) async {
|
2020-09-21 11:50:26 +00:00
|
|
|
final cryptoCurrency = appStore.wallet.currency;
|
2020-12-15 16:29:10 +00:00
|
|
|
fiatConversionStore.prices[appStore.wallet.currency] =
|
|
|
|
await FiatConversionService.fetchPrice(cryptoCurrency, fiatCurrency);
|
2020-09-21 11:50:26 +00:00
|
|
|
});
|
2020-12-15 16:29:10 +00:00
|
|
|
}
|