fix total balance calculation

This commit is contained in:
Akinwale Ariwodola 2019-03-30 11:01:25 +01:00
parent b1d8dade0d
commit 1d9218669b
2 changed files with 12 additions and 12 deletions

10
dist/bundle.js vendored
View file

@ -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,

View file

@ -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,