diff --git a/src/actions/general.js b/src/actions/general.js index 02e6d7fb..35607cfd 100644 --- a/src/actions/general.js +++ b/src/actions/general.js @@ -33,7 +33,7 @@ const selectAccountsBalanceAndOrder = createStructuredSelector({ export const refreshAccountsOrdering = () => (dispatch: *, getState: *) => { const all = selectAccountsBalanceAndOrder(getState()) - const allRatesAvailable = all.accountsBtcBalance.every(b => typeof b === 'number') + const allRatesAvailable = all.accountsBtcBalance.every(b => !!b) if (allRatesAvailable) { dispatch({ type: 'DB:REORDER_ACCOUNTS', diff --git a/src/helpers/accountOrdering.js b/src/helpers/accountOrdering.js index df303bb8..32cd30df 100644 --- a/src/helpers/accountOrdering.js +++ b/src/helpers/accountOrdering.js @@ -1,10 +1,11 @@ // @flow +import type { BigNumber } from 'bignumber.js' import type { Account } from '@ledgerhq/live-common/lib/types' type Param = { accounts: Account[], - accountsBtcBalance: number[], + accountsBtcBalance: BigNumber[], orderAccounts: string, } @@ -14,7 +15,7 @@ const sortMethod: { [_: SortMethod]: (Param) => string[] } = { balance: ({ accounts, accountsBtcBalance }) => accounts .map((a, i) => [a.id, accountsBtcBalance[i]]) - .sort((a, b) => a[1] - b[1]) + .sort((a, b) => a[1].minus(b[1]).toNumber()) .map(o => o[0]), name: ({ accounts }) =>