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

Hide conversions when API fails.

This commit is contained in:
Kevin Serrano 2016-08-16 14:49:21 -07:00
parent 9afa978121
commit 0b052e94cc

View File

@ -44,13 +44,22 @@ EthBalanceComponent.prototype.render = function () {
) )
} }
EthBalanceComponent.prototype.renderBalance = function (value, state) { EthBalanceComponent.prototype.renderBalance = function (value, state) {
console.log("THIS IS VALUE")
console.log(value)
console.log(state.conversionRate)
if (value === 'None') return value if (value === 'None') return value
var balanceObj = generateBalanceObject(value, state.shorten ? 1 : 3) var balanceObj = generateBalanceObject(value, state.shorten ? 1 : 3)
var balance var balance
var splitBalance = value.split(' ') var splitBalance = value.split(' ')
var ethNumber = splitBalance[0] var ethNumber = splitBalance[0]
var ethSuffix = splitBalance[1] var ethSuffix = splitBalance[1]
var fiatNumber = Number(splitBalance[0]) * state.conversionRate
if (state.conversionRate !== 'N/A') {
var fiatNumber = (Number(splitBalance[0]) * state.conversionRate).toFixed(2)
} else {
var fiatNumber = 'N/A'
}
var fiatSuffix = state.currentFiat var fiatSuffix = state.currentFiat
if (state.shorten) { if (state.shorten) {
@ -59,10 +68,6 @@ EthBalanceComponent.prototype.renderBalance = function (value, state) {
balance = balanceObj.balance balance = balanceObj.balance
} }
if (fiatNumber !== 'N/A') {
fiatNumber = fiatNumber.toFixed(2)
}
var label = balanceObj.label var label = balanceObj.label
return ( return (
@ -98,7 +103,15 @@ EthBalanceComponent.prototype.renderBalance = function (value, state) {
position: 'bottom', position: 'bottom',
title: `${fiatNumber} ${fiatSuffix}`, title: `${fiatNumber} ${fiatSuffix}`,
}, [ }, [
h('.flex-row', { fiatDisplay (fiatNumber, fiatSuffix)
]),
])
)
}
function fiatDisplay (fiatNumber, fiatSuffix) {
if (fiatNumber !== 'N/A') {
return h('.flex-row', {
style: { style: {
alignItems: 'flex-end', alignItems: 'flex-end',
lineHeight: '13px', lineHeight: '13px',
@ -113,7 +126,7 @@ EthBalanceComponent.prototype.renderBalance = function (value, state) {
fontSize: '12px', fontSize: '12px',
color: '#333333', color: '#333333',
}, },
}, `= ${fiatNumber}`), }, fiatNumber),
h('div', { h('div', {
style: { style: {
color: '#AEAEAE', color: '#AEAEAE',
@ -121,8 +134,8 @@ EthBalanceComponent.prototype.renderBalance = function (value, state) {
fontSize: '12px', fontSize: '12px',
}, },
}, fiatSuffix), }, fiatSuffix),
]),
]),
]) ])
) } else {
return h('div')
}
} }