mirror of
https://github.com/heyman/heynote.git
synced 2024-11-21 23:43:22 +01:00
Support currency conversions with lower case currency codes
(except for the currency CUP since it clashes with the measurement unit "cup")
This commit is contained in:
parent
0c567384ee
commit
a415247e48
@ -2,7 +2,7 @@ let currenciesLoaded = false
|
||||
export async function loadCurrencies() {
|
||||
const data = await window.heynote.getCurrencyData()
|
||||
if (!currenciesLoaded)
|
||||
math.createUnit(data.base, {override:currenciesLoaded, aliases:[]})
|
||||
math.createUnit(data.base, {override:currenciesLoaded, aliases:[data.base.toLowerCase()]})
|
||||
Object.keys(data.rates)
|
||||
.filter(function (currency) {
|
||||
return currency !== data.base
|
||||
@ -10,7 +10,7 @@ export async function loadCurrencies() {
|
||||
.forEach(function (currency) {
|
||||
math.createUnit(currency, {
|
||||
definition: math.unit(1 / data.rates[currency], data.base),
|
||||
aliases: [],
|
||||
aliases: currency === "CUP" ? [] : [currency.toLowerCase()], // Lowercase CUP clashes with the measurement unit cup
|
||||
}, {override: currenciesLoaded})
|
||||
})
|
||||
currenciesLoaded = true
|
||||
|
Loading…
Reference in New Issue
Block a user