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,
|
||||
});
|
||||
|
||||
const upgradeMarginsConection = (
|
||||
const upgradeMarginsConnection = (
|
||||
marketId: string,
|
||||
margins: MarginsQuery['party'] | null
|
||||
) => {
|
||||
@ -270,7 +270,7 @@ export const rejoinPositionData = (
|
||||
updatedAt: node.updatedAt,
|
||||
market:
|
||||
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);
|
||||
return sortBy(
|
||||
getMetrics(positionsData, accounts as Account[] | null),
|
||||
'updatedAt'
|
||||
).reverse();
|
||||
'marketName'
|
||||
);
|
||||
}
|
||||
);
|
||||
|
@ -1,3 +1,4 @@
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import { useCallback, useMemo, useRef } from 'react';
|
||||
import type { RefObject } from 'react';
|
||||
import { BigNumber } from 'bignumber.js';
|
||||
@ -41,6 +42,7 @@ export const usePositionsData = (
|
||||
assetSymbol?: string
|
||||
) => {
|
||||
const variables = useMemo(() => ({ partyId }), [partyId]);
|
||||
const summaryRow = useRef<ReturnType<typeof getSummaryRow>>();
|
||||
const dataRef = useRef<Position[] | null>(null);
|
||||
const update = useCallback(
|
||||
({ data }: { data: Position[] | null }) => {
|
||||
@ -66,9 +68,11 @@ export const usePositionsData = (
|
||||
const lastRow = dataRef.current?.length ?? -1;
|
||||
successCallback(rowsThisBlock, lastRow);
|
||||
if (gridRef.current?.api) {
|
||||
gridRef.current.api.setPinnedBottomRowData([
|
||||
getSummaryRow(rowsThisBlock),
|
||||
]);
|
||||
const updatedSummaryRow = getSummaryRow(rowsThisBlock);
|
||||
if (!isEqual(updatedSummaryRow, summaryRow.current)) {
|
||||
summaryRow.current = updatedSummaryRow;
|
||||
gridRef.current.api.setPinnedBottomRowData([updatedSummaryRow]);
|
||||
}
|
||||
}
|
||||
},
|
||||
[gridRef]
|
||||
|
Loading…
Reference in New Issue
Block a user