Browse Source

Fix bug with sort due to recent bignumber.js change

(this was a problem because merge 2 PR at same time^^)
master
Gaëtan Renaudeau 7 years ago
parent
commit
ba3e7f1aa4
  1. 2
      src/actions/general.js
  2. 5
      src/helpers/accountOrdering.js

2
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',

5
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 }) =>

Loading…
Cancel
Save