fix(1649): don't use old data on rerender when data update from provider is handled by component (#1707)

This commit is contained in:
Bartłomiej Głownia 2022-10-11 13:52:35 +02:00 committed by GitHub
parent 224ec8653b
commit 9dfe8789d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 9 deletions

View File

@ -39,7 +39,9 @@ const AccountsManager = () => {
update, update,
variables, variables,
}); });
dataRef.current = data; if (!dataRef.current && data) {
dataRef.current = data;
}
const getRows = async ({ const getRows = async ({
successCallback, successCallback,
startRow, startRow,

View File

@ -43,7 +43,9 @@ export const AccountManager = ({
update, update,
variables, variables,
}); });
dataRef.current = data; if (!dataRef.current && data) {
dataRef.current = data;
}
const getRows = async ({ const getRows = async ({
successCallback, successCallback,
startRow, startRow,

View File

@ -84,8 +84,10 @@ export const useFillsList = ({ partyId, gridRef, scrolledToTop }: Props) => {
(TradeEdge | null)[], (TradeEdge | null)[],
Trade[] Trade[]
>({ dataProvider: fillsWithMarketProvider, update, insert, variables }); >({ dataProvider: fillsWithMarketProvider, update, insert, variables });
totalCountRef.current = totalCount; if (!dataRef.current && data) {
dataRef.current = data; totalCountRef.current = totalCount;
dataRef.current = data;
}
const getRows = makeInfiniteScrollGetRows<TradeEdge>( const getRows = makeInfiniteScrollGetRows<TradeEdge>(
newRows, newRows,

View File

@ -146,7 +146,9 @@ export const DepthChartContainer = ({ marketId }: DepthChartManagerProps) => {
variables, variables,
}); });
marketDataRef.current = marketData; if (marketDataRef.current && marketData) {
marketDataRef.current = marketData;
}
useEffect(() => { useEffect(() => {
if (!marketData || !market || !data) { if (!marketData || !market || !data) {

View File

@ -84,8 +84,10 @@ export const useOrderListData = ({
insert, insert,
variables, variables,
}); });
totalCountRef.current = totalCount; if (!dataRef.current && data) {
dataRef.current = data; totalCountRef.current = totalCount;
dataRef.current = data;
}
const getRows = makeInfiniteScrollGetRows<OrderEdge>( const getRows = makeInfiniteScrollGetRows<OrderEdge>(
newRows, newRows,

View File

@ -58,7 +58,9 @@ export const usePositionsData = (
update, update,
variables, variables,
}); });
dataRef.current = assetSymbol ? filter(data, { assetSymbol }) : data; if (!dataRef.current && data) {
dataRef.current = assetSymbol ? filter(data, { assetSymbol }) : data;
}
const getRows = useCallback( const getRows = useCallback(
async ({ successCallback, startRow, endRow }: GetRowsParams) => { async ({ successCallback, startRow, endRow }: GetRowsParams) => {
const rowsThisBlock = dataRef.current const rowsThisBlock = dataRef.current

View File

@ -93,7 +93,9 @@ export const TradesContainer = ({ marketId }: TradesContainerProps) => {
variables, variables,
}); });
totalCountRef.current = totalCount; totalCountRef.current = totalCount;
dataRef.current = data; if (!dataRef.current && data) {
dataRef.current = data;
}
const getRows = makeInfiniteScrollGetRows<TradeEdge>( const getRows = makeInfiniteScrollGetRows<TradeEdge>(
newRows, newRows,