mirror of
https://github.com/heyman/heynote.git
synced 2024-11-25 01:13:17 +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() {
|
export async function loadCurrencies() {
|
||||||
const data = await window.heynote.getCurrencyData()
|
const data = await window.heynote.getCurrencyData()
|
||||||
if (!currenciesLoaded)
|
if (!currenciesLoaded)
|
||||||
math.createUnit(data.base, {override:currenciesLoaded, aliases:[]})
|
math.createUnit(data.base, {override:currenciesLoaded, aliases:[data.base.toLowerCase()]})
|
||||||
Object.keys(data.rates)
|
Object.keys(data.rates)
|
||||||
.filter(function (currency) {
|
.filter(function (currency) {
|
||||||
return currency !== data.base
|
return currency !== data.base
|
||||||
@ -10,7 +10,7 @@ export async function loadCurrencies() {
|
|||||||
.forEach(function (currency) {
|
.forEach(function (currency) {
|
||||||
math.createUnit(currency, {
|
math.createUnit(currency, {
|
||||||
definition: math.unit(1 / data.rates[currency], data.base),
|
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})
|
}, {override: currenciesLoaded})
|
||||||
})
|
})
|
||||||
currenciesLoaded = true
|
currenciesLoaded = true
|
||||||
|
Loading…
Reference in New Issue
Block a user