fix balance table sorting crash

This commit is contained in:
Mikhail Mikheev 2019-06-05 13:41:01 +04:00
parent 6c5711d6d9
commit 4b0cac5eb0
2 changed files with 5 additions and 5 deletions

View File

@ -12,7 +12,6 @@ export const buildOrderFieldFrom = (attr: string) => `${attr}Order`
const desc = (a: Object, b: Object, orderBy: string, orderProp: boolean) => {
const order = orderProp ? buildOrderFieldFrom(orderBy) : orderBy
console.log(a, b, orderBy, orderProp)
if (b[order] < a[order]) {
return -1
@ -25,13 +24,14 @@ const desc = (a: Object, b: Object, orderBy: string, orderProp: boolean) => {
}
// eslint-disable-next-line
export const stableSort = (dataArray: List<any>, cmp: any, fixed: boolean): Array<SortRow> => {
export const stableSort = (dataArray: List<any>, cmp: any, fixed: boolean): List<any> => {
const fixedElems: List<any> = fixed ? dataArray.filter((elem: any) => elem.fixed) : List([])
const data: List<any> = fixed ? dataArray.filter((elem: any) => !elem[FIXED]) : dataArray
const stabilizedThis = data.map((el, index) => [el, index])
let stabilizedThis = data.map((el, index) => [el, index])
stabilizedThis.sort((a, b) => {
stabilizedThis = stabilizedThis.sort((a, b) => {
const order = cmp(a[0], b[0])
if (order !== 0) {
return order
}

View File

@ -30,7 +30,7 @@ export const getBalanceData = (activeTokens: List<Token>): List<BalanceRow> => {
export const generateColumns = () => {
const assetColumn: Column = {
id: BALANCE_TABLE_ASSET_ID,
order: false,
order: true,
disablePadding: false,
label: 'Asset',
custom: false,