fix(liquidity): use LP order ID as ag-grid row ID (#3615)

This commit is contained in:
m.ray 2023-05-05 02:23:33 +03:00 committed by GitHub
parent 7b15d2db10
commit 85e293f3ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 26 deletions

View File

@ -22,7 +22,6 @@ import type {
LiquidityProvisionsQueryVariables,
LiquidityProvisionsUpdateSubscription,
} from './__generated__/MarketLiquidity';
import type { IterableElement } from 'type-fest';
export const liquidityProvisionsDataProvider = makeDataProvider<
LiquidityProvisionsQuery,
@ -39,8 +38,8 @@ export const liquidityProvisionsDataProvider = makeDataProvider<
) => {
return produce(data || [], (draft) => {
deltas?.forEach((delta) => {
const id = getId(delta);
const index = draft.findIndex((a) => getId(a) === id);
const id = delta.id;
const index = draft.findIndex((a) => delta.id === id);
if (index !== -1) {
draft[index].commitmentAmount = delta.commitmentAmount;
draft[index].fee = delta.fee;
@ -76,27 +75,6 @@ export const liquidityProvisionsDataProvider = makeDataProvider<
},
});
function isLpFragment(
entry:
| LiquidityProvisionFieldsFragment
| IterableElement<
LiquidityProvisionsUpdateSubscription['liquidityProvisions']
>
): entry is LiquidityProvisionFieldsFragment {
return entry.__typename === 'LiquidityProvision';
}
export const getId = (
entry:
| LiquidityProvisionFieldsFragment
| IterableElement<
LiquidityProvisionsUpdateSubscription['liquidityProvisions']
>
) =>
isLpFragment(entry)
? `${entry.party.id}${entry.status}${entry.createdAt}`
: `${entry.partyID}${entry.status}${entry.createdAt}`;
export const marketLiquidityDataProvider = makeDataProvider<
MarketLpQuery,
MarketLpQuery,

View File

@ -17,7 +17,6 @@ import type { ValueFormatterParams } from 'ag-grid-community';
import BigNumber from 'bignumber.js';
import { LiquidityProvisionStatusMapping } from '@vegaprotocol/types';
import type { LiquidityProvisionData } from './liquidity-data-provider';
import { getId } from './liquidity-data-provider';
const percentageFormatter = ({ value }: ValueFormatterParams) => {
if (!value) return '-';
@ -56,7 +55,7 @@ export const LiquidityTable = forwardRef<AgGridReact, LiquidityTableProps>(
<AgGrid
style={{ width: '100%', height: '100%' }}
overlayNoRowsTemplate={t('No liquidity provisions')}
getRowId={({ data }) => getId(data)}
getRowId={({ data }) => data.id}
ref={ref}
tooltipShowDelay={500}
defaultColDef={{