fix: order positions by market name instead of updatedAt (#1902)
This commit is contained in:
parent
f5ea0563b3
commit
13a77d1583
@ -234,7 +234,7 @@ export const positionsDataProvider = makeDataProvider<
|
|||||||
subscriptionData.positions,
|
subscriptionData.positions,
|
||||||
});
|
});
|
||||||
|
|
||||||
const upgradeMarginsConection = (
|
const upgradeMarginsConnection = (
|
||||||
marketId: string,
|
marketId: string,
|
||||||
margins: MarginsQuery['party'] | null
|
margins: MarginsQuery['party'] | null
|
||||||
) => {
|
) => {
|
||||||
@ -270,7 +270,7 @@ export const rejoinPositionData = (
|
|||||||
updatedAt: node.updatedAt,
|
updatedAt: node.updatedAt,
|
||||||
market:
|
market:
|
||||||
marketsData?.find((market) => market.id === node.market.id) || null,
|
marketsData?.find((market) => market.id === node.market.id) || null,
|
||||||
margins: upgradeMarginsConection(node.market.id, margins),
|
margins: upgradeMarginsConnection(node.market.id, margins),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ export const positionsMetricsDataProvider = makeDerivedDataProvider<
|
|||||||
const positionsData = rejoinPositionData(positions, marketsData, margins);
|
const positionsData = rejoinPositionData(positions, marketsData, margins);
|
||||||
return sortBy(
|
return sortBy(
|
||||||
getMetrics(positionsData, accounts as Account[] | null),
|
getMetrics(positionsData, accounts as Account[] | null),
|
||||||
'updatedAt'
|
'marketName'
|
||||||
).reverse();
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import isEqual from 'lodash/isEqual';
|
||||||
import { useCallback, useMemo, useRef } from 'react';
|
import { useCallback, useMemo, useRef } from 'react';
|
||||||
import type { RefObject } from 'react';
|
import type { RefObject } from 'react';
|
||||||
import { BigNumber } from 'bignumber.js';
|
import { BigNumber } from 'bignumber.js';
|
||||||
@ -41,6 +42,7 @@ export const usePositionsData = (
|
|||||||
assetSymbol?: string
|
assetSymbol?: string
|
||||||
) => {
|
) => {
|
||||||
const variables = useMemo(() => ({ partyId }), [partyId]);
|
const variables = useMemo(() => ({ partyId }), [partyId]);
|
||||||
|
const summaryRow = useRef<ReturnType<typeof getSummaryRow>>();
|
||||||
const dataRef = useRef<Position[] | null>(null);
|
const dataRef = useRef<Position[] | null>(null);
|
||||||
const update = useCallback(
|
const update = useCallback(
|
||||||
({ data }: { data: Position[] | null }) => {
|
({ data }: { data: Position[] | null }) => {
|
||||||
@ -66,9 +68,11 @@ export const usePositionsData = (
|
|||||||
const lastRow = dataRef.current?.length ?? -1;
|
const lastRow = dataRef.current?.length ?? -1;
|
||||||
successCallback(rowsThisBlock, lastRow);
|
successCallback(rowsThisBlock, lastRow);
|
||||||
if (gridRef.current?.api) {
|
if (gridRef.current?.api) {
|
||||||
gridRef.current.api.setPinnedBottomRowData([
|
const updatedSummaryRow = getSummaryRow(rowsThisBlock);
|
||||||
getSummaryRow(rowsThisBlock),
|
if (!isEqual(updatedSummaryRow, summaryRow.current)) {
|
||||||
]);
|
summaryRow.current = updatedSummaryRow;
|
||||||
|
gridRef.current.api.setPinnedBottomRowData([updatedSummaryRow]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[gridRef]
|
[gridRef]
|
||||||
|
Loading…
Reference in New Issue
Block a user