diff --git a/react/src/components/dashboard/walletsBalance/walletsBalance.js b/react/src/components/dashboard/walletsBalance/walletsBalance.js index c0f79c5..72a4e43 100755 --- a/react/src/components/dashboard/walletsBalance/walletsBalance.js +++ b/react/src/components/dashboard/walletsBalance/walletsBalance.js @@ -70,14 +70,13 @@ class WalletsBalance extends React.Component { if (_mode === 'full') { _balance = this.props.ActiveCoin.balance || 0; - } else { + } else if (_mode === 'basilisk') { if (this.props.ActiveCoin.cache) { const _cache = this.props.ActiveCoin.cache; const _coin = this.props.ActiveCoin.coin; const _address = this.props.ActiveCoin.activeAddress; - if (type === 'main' && - _mode === 'basilisk' && + if (type === 'transparent' && _address && _cache[_coin] && _cache[_coin][_address] && @@ -88,7 +87,6 @@ class WalletsBalance extends React.Component { } if (type === 'interest' && - _mode === 'basilisk' && _address && _cache[_coin] && _cache[_coin][_address] && @@ -99,7 +97,6 @@ class WalletsBalance extends React.Component { } if (type === 'total' && - _mode === 'basilisk' && _address && _cache[_coin] && _cache[_coin][_address] && @@ -113,6 +110,30 @@ class WalletsBalance extends React.Component { _balance = _regBalance + _regInterest; } } + } else if (_mode === 'native') { + if (type === 'total' && + this.props.ActiveCoin.balance && + this.props.ActiveCoin.balance.total) { + _balance = this.props.ActiveCoin.balance.total; + } + + if (type === 'interest' && + this.props.Dashboard.progress && + this.props.Dashboard.progress.interest) { + _balance = this.props.Dashboard.progress.interest; + } + + if (type === 'private' && + this.props.ActiveCoin.balance && + this.props.ActiveCoin.balance.private) { + _balance = this.props.ActiveCoin.balance.private; + } + + if (type === 'transparent' && + this.props.ActiveCoin.balance && + this.props.ActiveCoin.balance.transparent) { + _balance = this.props.ActiveCoin.balance.transparent; + } } return _balance; diff --git a/react/src/components/dashboard/walletsBalance/walletsBalance.render.js b/react/src/components/dashboard/walletsBalance/walletsBalance.render.js index e00db48..4d28a63 100644 --- a/react/src/components/dashboard/walletsBalance/walletsBalance.render.js +++ b/react/src/components/dashboard/walletsBalance/walletsBalance.render.js @@ -37,14 +37,8 @@ const WalletsBalanceRender = function() { - { this.isNativeMode() ? - this.props.ActiveCoin.balance.transparent ? this.props.ActiveCoin.balance.transparent : '-' - : - - { Config.roundValues ? formatValue('round', this.renderBalance('main'), -6) : this.renderBalance('main') } { this.props.ActiveCoin.coin } - - } + title={ Config.roundValues ? formatValue('round', this.renderBalance('transparent'), -6) : this.renderBalance('transparent') }> + { Config.roundValues ? formatValue('round', this.renderBalance('transparent'), -6) : this.renderBalance('transparent') } { this.props.ActiveCoin.coin } @@ -63,8 +57,8 @@ const WalletsBalanceRender = function() { - { this.props.ActiveCoin.balance.private ? (Config.roundValues ? formatValue('round', this.props.ActiveCoin.balance.private, -6) : this.props.ActiveCoin.balance.private) : '-' } + title={ Config.roundValues ? formatValue('round', this.renderBalance('private'), -6) : this.renderBalance('private') }> + { Config.roundValues ? formatValue('round', this.renderBalance('private'), -6) : this.renderBalance('private') } @@ -84,15 +78,8 @@ const WalletsBalanceRender = function() { - { this.isNativeMode() ? - this.props.Dashboard.progress - && this.props.Dashboard.progress.interest ? this.props.Dashboard.progress.interest : '-' - : - - { Config.roundValues ? formatValue('round', this.renderBalance('interest'), -6) : this.renderBalance('interest') } { this.props.ActiveCoin.coin } - - } + title={ Config.roundValues ? formatValue('round', this.renderBalance('interest'), -6) : this.renderBalance('interest') }> + { Config.roundValues ? formatValue('round', this.renderBalance('interest'), -6) : this.renderBalance('interest') } @@ -112,14 +99,8 @@ const WalletsBalanceRender = function() { - { this.isNativeMode() ? - this.props.ActiveCoin.balance.total ? this.props.ActiveCoin.balance.total : '-' - : - - { Config.roundValues ? formatValue('round', this.renderBalance('total'), -6) : this.renderBalance('total') } { this.props.ActiveCoin.coin } - - } + title={ Config.roundValues ? formatValue('round', this.renderBalance('total'), -6) : this.renderBalance('total') }> + { Config.roundValues ? formatValue('round', this.renderBalance('total'), -6) : this.renderBalance('total') } diff --git a/react/src/util/formatValue.js b/react/src/util/formatValue.js index f28b22e..c355e8f 100644 --- a/react/src/util/formatValue.js +++ b/react/src/util/formatValue.js @@ -1,5 +1,6 @@ // ref: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Math/round#Decimal_rounding export function formatValue(formatType, formatValue, formatExp) { + let _formatExp; /** * Decimal adjustment of a number. * @@ -31,19 +32,21 @@ export function formatValue(formatType, formatValue, formatExp) { return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp)); } - if (formatValue >= 1) { - formatExp = -3; + if (Math.abs(Number(formatValue)) >= 1) { + _formatExp = -3; + } else { + _formatExp = formatExp; } switch (formatType) { case 'round': - return decimalAdjust('round', formatValue, formatExp); + return decimalAdjust('round', formatValue, _formatExp); break; case 'floor': - return decimalAdjust('floor', formatValue, formatExp); + return decimalAdjust('floor', formatValue, _formatExp); break; case 'ceil': - return decimalAdjust('ceil', formatValue, formatExp); + return decimalAdjust('ceil', formatValue, _formatExp); break; } } \ No newline at end of file