diff --git a/dist/bundle.js b/dist/bundle.js index 141c89c..8d37246 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -3647,13 +3647,13 @@ function doUpdateTotalBalance() { var _getState2 = getState(), totalBalanceInStore = _getState2.wallet.totalBalance; - _lbry2.default.account_list().then(function (accounts) { - var totalSatoshis = accounts.lbc_mainnet.reduce(function (a, b) { - if (!a.satoshis) return b.satoshis; - if (!b.satoshis) return a.satoshis; + _lbry2.default.account_list().then(function (accountList) { + var accounts = accountList.lbc_mainnet; + + var totalSatoshis = accounts.length === 1 ? accounts[0].satoshis : accounts.reduce(function (a, b) { return a.satoshis + b.satoshis; }); - var totalBalance = totalSatoshis / Math.pow(10, 8); + var totalBalance = (Number.isNaN(totalSatoshis) ? 0 : totalSatoshis) / Math.pow(10, 8); if (totalBalanceInStore !== totalBalance) { dispatch({ type: ACTIONS.UPDATE_TOTAL_BALANCE, diff --git a/src/redux/actions/wallet.js b/src/redux/actions/wallet.js index fb35e6e..7500e44 100644 --- a/src/redux/actions/wallet.js +++ b/src/redux/actions/wallet.js @@ -29,13 +29,13 @@ export function doUpdateTotalBalance() { const { wallet: { totalBalance: totalBalanceInStore }, } = getState(); - Lbry.account_list().then(accounts => { - const totalSatoshis = accounts.lbc_mainnet.reduce((a, b) => { - if (!a.satoshis) return b.satoshis; - if (!b.satoshis) return a.satoshis; - return a.satoshis + b.satoshis; - }); - const totalBalance = totalSatoshis / 10 ** 8; + Lbry.account_list().then(accountList => { + const { lbc_mainnet: accounts } = accountList; + const totalSatoshis = + accounts.length === 1 + ? accounts[0].satoshis + : accounts.reduce((a, b) => a.satoshis + b.satoshis); + const totalBalance = (Number.isNaN(totalSatoshis) ? 0 : totalSatoshis) / 10 ** 8; if (totalBalanceInStore !== totalBalance) { dispatch({ type: ACTIONS.UPDATE_TOTAL_BALANCE,