fix: fix empty rows on empty collateral list (#2312)
* fix: fix empty rows on empty collateral list * fix: fix empty rows on empty collateral list * fix: fix empty rows on empty collateral list
This commit is contained in:
parent
5531566e2f
commit
aafa3d7256
@ -1,4 +1,5 @@
|
||||
/* eslint-disable */
|
||||
process.env.TZ = 'UTC';
|
||||
export default {
|
||||
displayName: 'explorer',
|
||||
preset: '../../jest.preset.js',
|
||||
|
@ -43,7 +43,7 @@ export const AccountManager = ({
|
||||
const rowsThisBlock = dataRef.current
|
||||
? dataRef.current.slice(startRow, endRow)
|
||||
: [];
|
||||
const lastRow = dataRef.current?.length ?? -1;
|
||||
const lastRow = dataRef.current?.length ?? undefined;
|
||||
successCallback(rowsThisBlock, lastRow);
|
||||
},
|
||||
[]
|
||||
|
@ -159,7 +159,7 @@ describe('useOrderListData Hook', () => {
|
||||
expect(loadMock).toHaveBeenCalled();
|
||||
expect(successCallback).toHaveBeenLastCalledWith(
|
||||
mockDelta.map((item) => item.node),
|
||||
-1
|
||||
undefined
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -9,7 +9,7 @@ const getLastRow = (
|
||||
blockLength: number,
|
||||
totalCount?: number
|
||||
) => {
|
||||
let lastRow = -1;
|
||||
let lastRow = undefined;
|
||||
if (totalCount !== undefined) {
|
||||
if (!totalCount) {
|
||||
lastRow = 0;
|
||||
@ -50,9 +50,15 @@ export const makeInfiniteScrollGetRows =
|
||||
const rowsThisBlock = data.current
|
||||
? data.current.slice(startRow, endRow).map((edge) => edge?.node)
|
||||
: [];
|
||||
const lastRow =
|
||||
getLastRow(startRow, endRow, rowsThisBlock.length, totalCount.current) -
|
||||
newRows.current;
|
||||
const currentLastNumber = getLastRow(
|
||||
startRow,
|
||||
endRow,
|
||||
rowsThisBlock.length,
|
||||
totalCount.current
|
||||
);
|
||||
const lastRow = currentLastNumber
|
||||
? currentLastNumber - newRows.current
|
||||
: currentLastNumber;
|
||||
successCallback(rowsThisBlock, lastRow);
|
||||
} catch (e) {
|
||||
failCallback();
|
||||
|
Loading…
Reference in New Issue
Block a user