Fix decimal bug

Fix bug that causes the decimal option to be disabled when switching from Currency to another conversion category.
This commit is contained in:
Rose 2022-10-05 12:38:15 -04:00
commit 332bdfdc71

View file

@ -174,6 +174,8 @@ void UnitConverterViewModel::ResetCategory()
m_isInputBlocked = false; m_isInputBlocked = false;
SetSelectedUnits(); SetSelectedUnits();
UpdateIsDecimalEnabled();
IsCurrencyLoadingVisible = m_IsCurrencyCurrentCategory && !m_isCurrencyDataLoaded; IsCurrencyLoadingVisible = m_IsCurrencyCurrentCategory && !m_isCurrencyDataLoaded;
IsDropDownEnabled = m_Units->GetAt(0) != EMPTY_UNIT; IsDropDownEnabled = m_Units->GetAt(0) != EMPTY_UNIT;
@ -693,7 +695,8 @@ void UnitConverterViewModel::RefreshCurrencyRatios()
auto that(this); auto that(this);
auto refreshTask = create_task([that] { return that->m_model->RefreshCurrencyRatios().get(); }); auto refreshTask = create_task([that] { return that->m_model->RefreshCurrencyRatios().get(); });
refreshTask.then( refreshTask.then(
[that](const pair<bool, wstring>& refreshResult) { [that](const pair<bool, wstring>& refreshResult)
{
bool didLoad = refreshResult.first; bool didLoad = refreshResult.first;
wstring timestamp = refreshResult.second; wstring timestamp = refreshResult.second;
@ -870,7 +873,13 @@ void UnitConverterViewModel::UpdateCurrencyFormatter()
void UnitConverterViewModel::UpdateIsDecimalEnabled() void UnitConverterViewModel::UpdateIsDecimalEnabled()
{ {
if (!IsCurrencyCurrentCategory || CurrencyFormatterFrom == nullptr) if (!IsCurrencyCurrentCategory)
{
IsDecimalEnabled = true; // Always have decimal enabled if we aren't in a currency category.
return;
}
if (CurrencyFormatterFrom == nullptr)
return; return;
IsDecimalEnabled = CurrencyFormatterFrom->FractionDigits > 0; IsDecimalEnabled = CurrencyFormatterFrom->FractionDigits > 0;
} }