updates for cross-device sync #130

Merged
akinwale merged 7 commits from sync into master 2019-04-18 09:56:17 +02:00
2 changed files with 12 additions and 12 deletions
Showing only changes of commit 1d9218669b - Show all commits

10
dist/bundle.js vendored
View file

@ -3647,13 +3647,13 @@ function doUpdateTotalBalance() {
var _getState2 = getState(), var _getState2 = getState(),
totalBalanceInStore = _getState2.wallet.totalBalance; totalBalanceInStore = _getState2.wallet.totalBalance;
_lbry2.default.account_list().then(function (accounts) { _lbry2.default.account_list().then(function (accountList) {
var totalSatoshis = accounts.lbc_mainnet.reduce(function (a, b) { var accounts = accountList.lbc_mainnet;
if (!a.satoshis) return b.satoshis;
if (!b.satoshis) return a.satoshis; var totalSatoshis = accounts.length === 1 ? accounts[0].satoshis : accounts.reduce(function (a, b) {
return a.satoshis + b.satoshis; 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) { if (totalBalanceInStore !== totalBalance) {
dispatch({ dispatch({
type: ACTIONS.UPDATE_TOTAL_BALANCE, type: ACTIONS.UPDATE_TOTAL_BALANCE,

View file

@ -29,13 +29,13 @@ export function doUpdateTotalBalance() {
const { const {
wallet: { totalBalance: totalBalanceInStore }, wallet: { totalBalance: totalBalanceInStore },
} = getState(); } = getState();
Lbry.account_list().then(accounts => { Lbry.account_list().then(accountList => {
const totalSatoshis = accounts.lbc_mainnet.reduce((a, b) => { const { lbc_mainnet: accounts } = accountList;
if (!a.satoshis) return b.satoshis; const totalSatoshis =
if (!b.satoshis) return a.satoshis; accounts.length === 1
return a.satoshis + b.satoshis; ? accounts[0].satoshis
}); : accounts.reduce((a, b) => a.satoshis + b.satoshis);
const totalBalance = totalSatoshis / 10 ** 8; const totalBalance = (Number.isNaN(totalSatoshis) ? 0 : totalSatoshis) / 10 ** 8;
if (totalBalanceInStore !== totalBalance) { if (totalBalanceInStore !== totalBalance) {
dispatch({ dispatch({
type: ACTIONS.UPDATE_TOTAL_BALANCE, type: ACTIONS.UPDATE_TOTAL_BALANCE,