Fix issue where if given a balance that does not need to be parsed will not be parsed

This commit is contained in:
Frankie 2016-08-19 17:18:11 -07:00
parent 30af7e96cb
commit edfb0eb968
3 changed files with 10 additions and 7 deletions

View File

@ -15,8 +15,8 @@ function EthBalanceComponent () {
EthBalanceComponent.prototype.render = function () {
var state = this.props
var style = state.style
const value = formatBalance(state.value, 6)
var needsParse = this.props.needsParse !== undefined ? this.props.needsParse : true
const value = formatBalance(state.value, 6, needsParse)
var width = state.width
return (
@ -29,12 +29,13 @@ EthBalanceComponent.prototype.render = function () {
display: 'inline',
width: width,
},
}, this.renderBalance(value, state)),
}, this.renderBalance(value)),
])
)
}
EthBalanceComponent.prototype.renderBalance = function (value, state) {
EthBalanceComponent.prototype.renderBalance = function (value) {
var state = this.props
if (value === 'None') return value
var balanceObj = generateBalanceObject(value, state.shorten ? 1 : 3)
var balance
@ -68,7 +69,7 @@ EthBalanceComponent.prototype.renderBalance = function (value, state) {
width: '100%',
textAlign: 'right',
},
}, balance),
}, this.props.incoming ? `+${balance}` : balance),
h('div', {
style: {
color: ' #AEAEAE',

View File

@ -99,6 +99,8 @@ ShiftListItem.prototype.renderUtilComponents = function () {
value: `${props.response.outgoingCoin}`,
width: '55px',
shorten: true,
needsParse: false,
incoming: true,
style: {
fontSize: '15px',
color: '#01888C',

View File

@ -92,8 +92,8 @@ function parseBalance (balance) {
// Takes wei hex, returns an object with three properties.
// Its "formatted" property is what we generally use to render values.
function formatBalance (balance, decimalsToKeep) {
var parsed = parseBalance(balance)
function formatBalance (balance, decimalsToKeep, needsParse = true) {
var parsed = needsParse ? parseBalance(balance) : balance.split('.')
var beforeDecimal = parsed[0]
var afterDecimal = parsed[1]
var formatted = 'None'