diff --git a/react/src/components/dashboard/receiveCoin/receiveCoin.js b/react/src/components/dashboard/receiveCoin/receiveCoin.js index 9193512..34303a6 100644 --- a/react/src/components/dashboard/receiveCoin/receiveCoin.js +++ b/react/src/components/dashboard/receiveCoin/receiveCoin.js @@ -22,9 +22,12 @@ class ReceiveCoin extends React.Component { this.state = { openDropMenu: false, + hideZeroAdresses: false, }; this.openDropMenu = this.openDropMenu.bind(this); this.handleClickOutside = this.handleClickOutside.bind(this); + this.toggleVisibleAddress = this.toggleVisibleAddress.bind(this); + this.checkTotalBalance = this.checkTotalBalance.bind(this); } componentWillMount() { @@ -108,6 +111,47 @@ class ReceiveCoin extends React.Component { Store.dispatch(getNewKMDAddresses(this.props.coin, type)); } + toggleVisibleAddress() { + this.setState(Object.assign({}, this.state, { + hideZeroAddresses: !this.state.hideZeroAddresses, + })); + } + + checkTotalBalance() { + let _balance = '0'; + const _mode = this.props.mode; + + if (_mode === 'full') { + _balance = this.props.balance || 0; + } else if (_mode === 'basilisk') { + if (this.props.cache) { + const _cache = this.props.cache; + const _coin = this.props.coin; + const _address = this.props.activeAddress; + + if (_address && + _cache[_coin] && + _cache[_coin][_address] && + _cache[_coin][_address].getbalance && + _cache[_coin][_address].getbalance.data && + (_cache[_coin][_address].getbalance.data.balance || + _cache[_coin][_address].getbalance.data.interest)) { + const _regBalance = _cache[_coin][_address].getbalance.data.balance ? _cache[_coin][_address].getbalance.data.balance : 0; + const _regInterest = _cache[_coin][_address].getbalance.data.interest ? _cache[_coin][_address].getbalance.data.interest : 0; + + _balance = _regBalance + _regInterest; + } + } + } else if (_mode === 'native') { + if (this.props.balance && + this.props.balance.total) { + _balance = this.props.balance.total; + } + } + + return _balance; + } + renderAddressList(type) { const _addresses = this.props.addresses; const _cache = this.props.cache; @@ -134,9 +178,17 @@ class ReceiveCoin extends React.Component { && _cache[_coin][address.address].getbalance.data.interest ? _cache[_coin][address.address].getbalance.data.interest : 'N/A'; } - items.push( - AddressItemRender.call(this, address, type) - ); + if (this.state.hideZeroAddresses) { + if (!this.hasNoAmount) { + items.push( + AddressItemRender.call(this, address, type) + ); + } + } else { + items.push( + AddressItemRender.call(this, address, type) + ); + } } return items; diff --git a/react/src/components/dashboard/receiveCoin/receiveCoin.render.js b/react/src/components/dashboard/receiveCoin/receiveCoin.render.js index 108fb88..de187d2 100644 --- a/react/src/components/dashboard/receiveCoin/receiveCoin.render.js +++ b/react/src/components/dashboard/receiveCoin/receiveCoin.render.js @@ -76,8 +76,9 @@ export const ReceiveCoinRender = function() {
{this.isNativeMode() &&
-
+
{ translate('INDEX.GET_NEW_ADDRESS') } @@ -101,6 +102,23 @@ export const ReceiveCoinRender = function() {

{ translate('INDEX.RECEIVING_ADDRESS') }

+ { this.checkTotalBalance() === 0 && +
+
+ { translate('INDEX.TOGGLE_ZERO_ADDRESSES') } +
+ +
+ } { this.isNativeMode() ? diff --git a/react/src/components/dashboard/walletsNative/walletsNative.render.js b/react/src/components/dashboard/walletsNative/walletsNative.render.js index 72ecaaf..15d5be5 100644 --- a/react/src/components/dashboard/walletsNative/walletsNative.render.js +++ b/react/src/components/dashboard/walletsNative/walletsNative.render.js @@ -16,7 +16,7 @@ const WalletsNativeRender = function() { style={{ 'backgroundImage': `url("assets/images/bg/${this.defaultBG()}_transparent_header_bg.png")` }}>
  1. - + diff --git a/react/src/translate/en.js b/react/src/translate/en.js index 4d5937c..1832b9b 100644 --- a/react/src/translate/en.js +++ b/react/src/translate/en.js @@ -252,7 +252,8 @@ export const _lang = { 'ACTIVATING': 'Activating', 'QRCODE': 'Show QR code', 'SCAN_QR_CODE': 'Scan QR Code', - 'SCAN_QRCODE_WEBCAM': 'Scan QR Code with webcam' + 'SCAN_QRCODE_WEBCAM': 'Scan QR Code with webcam', + 'TOGGLE_ZERO_ADDRESSES': 'Toggle empty addresses' }, 'ATOMIC': { 'RAW_OUTPUT': 'Raw Output',