1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fixes conversion status for tokens without conversion rates

This commit is contained in:
Sara Reynolds 2018-07-11 15:00:14 -04:00
parent db4469794e
commit 8d8de0508a

View File

@ -82,16 +82,21 @@ CurrencyDisplay.prototype.getConvertedValueToRender = function (nonFormattedValu
numberOfDecimals: 2,
conversionRate,
})
convertedValue = Number(convertedValue).toFixed(2)
const upperCaseCurrencyCode = convertedCurrency.toUpperCase()
return currencies.find(currency => currency.code === upperCaseCurrencyCode)
? currencyFormatter.format(Number(convertedValue), {
code: upperCaseCurrencyCode,
})
: convertedValue
}
if (conversionRate == 0 && nonFormattedValue != 0) {
convertedValue = null
return convertedValue
}
else {
convertedValue == Number(convertedValue).toFixed(2)
const upperCaseCurrencyCode = convertedCurrency.toUpperCase()
return currencies.find(currency => currency.code === upperCaseCurrencyCode)
? currencyFormatter.format(Number(convertedValue), {
code: upperCaseCurrencyCode,
})
: convertedValue
}
}
CurrencyDisplay.prototype.handleChange = function (newVal) {
this.setState({ valueToRender: removeLeadingZeroes(newVal) })
@ -105,6 +110,7 @@ CurrencyDisplay.prototype.getInputWidth = function (valueToRender, readOnly) {
return (valueLength + decimalPointDeficit + 0.75) + 'ch'
}
CurrencyDisplay.prototype.render = function () {
const {
className = 'currency-display',
@ -121,6 +127,19 @@ CurrencyDisplay.prototype.render = function () {
const convertedValueToRender = this.getConvertedValueToRender(valueToRender)
function onlyRenderConversions() {
if (convertedValueToRender == null) {
return h('div', {
className: convertedBalanceClassName,
}, 'No Conversion Rate')
}
else {
return h('div', {
className: convertedBalanceClassName,
}, `${convertedValueToRender} ${convertedCurrency.toUpperCase()}`)
}
}
return h('div', {
className,
style: {
@ -157,11 +176,7 @@ CurrencyDisplay.prototype.render = function () {
]),
]),
h('div', {
className: convertedBalanceClassName,
}, `${convertedValueToRender} ${convertedCurrency.toUpperCase()}`),
]), onlyRenderConversions(),
])