ensure exchange is updated properly

This commit is contained in:
julian 2023-02-06 17:49:27 -06:00
parent 287c226416
commit 842593d6b2
2 changed files with 12 additions and 14 deletions

View file

@ -646,17 +646,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
final rateType = ref.watch(
prefsChangeNotifierProvider.select((value) => value.exchangeRateType));
ref.listen<String>(currentExchangeNameStateProvider, (previous, next) {
ref.read(exchangeFormStateProvider).updateExchange(
exchange: ref.read(exchangeProvider),
shouldUpdateData: true,
shouldNotifyListeners: true,
);
});
final isEstimated = ref.watch(prefsChangeNotifierProvider
.select((pref) => pref.exchangeRateType)) ==
ExchangeRateType.estimated;
final isEstimated = rateType == ExchangeRateType.estimated;
ref.listen(
exchangeFormStateProvider.select((value) => value.toAmountString),
@ -854,9 +844,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
to: ref.watch(exchangeFormStateProvider).toTicker,
fromAmount: ref.watch(exchangeFormStateProvider).sendAmount,
toAmount: ref.watch(exchangeFormStateProvider).receiveAmount,
fixedRate: ref.watch(prefsChangeNotifierProvider
.select((value) => value.exchangeRateType)) ==
ExchangeRateType.fixed,
fixedRate: rateType == ExchangeRateType.fixed,
reversed: ref.watch(
exchangeFormStateProvider.select((value) => value.reversed)),
),

View file

@ -60,6 +60,11 @@ class ExchangeProviderOptions extends ConsumerWidget {
ChangeNowExchange.exchangeName) {
ref.read(currentExchangeNameStateProvider.state).state =
ChangeNowExchange.exchangeName;
ref.read(exchangeFormStateProvider).updateExchange(
exchange: ref.read(exchangeProvider),
shouldUpdateData: true,
shouldNotifyListeners: true,
);
}
},
child: Container(
@ -290,6 +295,11 @@ class ExchangeProviderOptions extends ConsumerWidget {
MajesticBankExchange.exchangeName) {
ref.read(currentExchangeNameStateProvider.state).state =
MajesticBankExchange.exchangeName;
ref.read(exchangeFormStateProvider).updateExchange(
exchange: ref.read(exchangeProvider),
shouldUpdateData: true,
shouldNotifyListeners: true,
);
}
},
child: Container(