diff --git a/libs/positions/src/lib/positions-data-providers.ts b/libs/positions/src/lib/positions-data-providers.ts index 75b434eb9..5bea0f671 100644 --- a/libs/positions/src/lib/positions-data-providers.ts +++ b/libs/positions/src/lib/positions-data-providers.ts @@ -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' + ); } ); diff --git a/libs/positions/src/lib/use-positions-data.tsx b/libs/positions/src/lib/use-positions-data.tsx index 8b353d846..28d76312b 100644 --- a/libs/positions/src/lib/use-positions-data.tsx +++ b/libs/positions/src/lib/use-positions-data.tsx @@ -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>(); const dataRef = useRef(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]