mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Improve display of crypto currencies when selected as the 'Current Conversion'
This commit is contained in:
parent
c75918493d
commit
4011dac6f6
@ -5,6 +5,7 @@ const inherits = require('util').inherits
|
||||
const TokenBalance = require('./token-balance')
|
||||
const Identicon = require('./identicon')
|
||||
const currencyFormatter = require('currency-formatter')
|
||||
const currencies = require('currency-formatter/currencies');
|
||||
|
||||
const { formatBalance, generateBalanceObject } = require('../util')
|
||||
|
||||
@ -98,9 +99,13 @@ BalanceComponent.prototype.renderFiatAmount = function (fiatDisplayNumber, fiatS
|
||||
const shouldNotRenderFiat = fiatDisplayNumber === 'N/A' || Number(fiatDisplayNumber) === 0
|
||||
if (shouldNotRenderFiat) return null
|
||||
|
||||
const display = currencyFormatter.format(Number(fiatDisplayNumber), {
|
||||
code: fiatSuffix.toUpperCase(),
|
||||
})
|
||||
const upperCaseFiatSuffix = fiatSuffix.toUpperCase()
|
||||
|
||||
const display = currencies.find(currency => currency.code === upperCaseFiatSuffix)
|
||||
? currencyFormatter.format(Number(fiatDisplayNumber), {
|
||||
code: upperCaseFiatSuffix,
|
||||
})
|
||||
: `${fiatPrefix}${fiatDisplayNumber} ${upperCaseFiatSuffix}`
|
||||
|
||||
return h('div.fiat-amount', {
|
||||
style: {},
|
||||
@ -122,5 +127,9 @@ BalanceComponent.prototype.getFiatDisplayNumber = function (formattedBalance, co
|
||||
|
||||
const splitBalance = formattedBalance.split(' ')
|
||||
|
||||
return (Number(splitBalance[0]) * conversionRate).toFixed(2)
|
||||
const convertedNumber = (Number(splitBalance[0]) * conversionRate)
|
||||
const wholePart = Math.floor(convertedNumber)
|
||||
const decimalPart = convertedNumber - wholePart
|
||||
|
||||
return wholePart + Number(decimalPart.toPrecision(2))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user