Browse Source
Merge pull request #1207 from gre/fix-sorting-bug-with-bignumber.js
Fix bug with sort due to recent bignumber.js change
master
Gaëtan Renaudeau
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
4 additions and
3 deletions
-
src/actions/general.js
-
src/helpers/accountOrdering.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', |
|
|
|
|
|
@ -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 }) => |
|
|
|