(ios) Bug fix for currency converter: UI didn't update after forced refresh of exchange rates.
@@ -694,6 +694,9 @@ fileprivate struct Row: View, ViewName {
.onChange(of: parsedRow) { _ in
parsedRowDidChange()
}
+ .onChange(of: currencyPrefs.fiatExchangeRates) { _ in
+ exchangeRatesDidChange()
+ }
}
func currencyStyler() -> TextFieldCurrencyStyler {
@@ -711,6 +714,16 @@ fileprivate struct Row: View, ViewName {
parsedRowDidChange(forceRefresh: true)
}
+ func exchangeRatesDidChange() {
+ log.trace("[Row:\(currency)] exchangeRatesDidChange()")
+
+ if focusedField != .amountTextfield {
+ // The exchangeRates changed, and the user is modifying the value of some other currency.
+ // Which means we may need to recalculate and update our amount.
+ parsedRowDidChange(forceRefresh: true)
+ }
+ }
+
func clearTextField() {
log.trace("[Row:\(currency)] clearTextField()")
@@ -886,6 +899,9 @@ fileprivate struct Row_iOS14: View, ViewName {
.onChange(of: parsedRow) { _ in
parsedRowDidChange()
}
+ .onChange(of: currencyPrefs.fiatExchangeRates) { _ in
+ exchangeRatesDidChange()
+ }
}
func currencyStyler() -> TextFieldCurrencyStyler {
@@ -903,6 +919,16 @@ fileprivate struct Row_iOS14: View, ViewName {
parsedRowDidChange()
}
+ func exchangeRatesDidChange() {
+ log.trace("[Row:\(currency)] exchangeRatesDidChange()")
+
+ if focusedField != .amountTextfield {
+ // The exchangeRates changed, and the user is modifying the value of some other currency.
+ // Which means we may need to recalculate and update our amount.
+ parsedRowDidChange()
+ }
+ }
+
func clearTextField() {
log.trace("[Row:\(currency)] clearTextField()")
