[ENG-1080] fix explorer fetching (#1302)

fix fetching
This commit is contained in:
nikec
2023-09-06 12:42:02 +02:00
committed by GitHub
parent 65ea570d0b
commit def0cfea45
5 changed files with 8 additions and 27 deletions

View File

@@ -32,7 +32,6 @@ export interface UseGridListProps<IdT extends ItemId = number, DataT extends Ite
gap?: number | { x?: number; y?: number };
overscan?: number;
top?: number;
rowsBeforeLoadMore?: number;
onLoadMore?: () => void;
getItemId?: (index: number) => IdT | undefined;
getItemData?: (index: number) => DataT;
@@ -211,15 +210,10 @@ export const GridList = ({ grid, children, scrollRef }: GridListProps) => {
const lastRow = virtualRows[virtualRows.length - 1];
if (!lastRow) return;
const rowsBeforeLoadMore = grid.rowsBeforeLoadMore || 1;
const loadMoreFromRow = Math.ceil(grid.rowCount * 0.75);
const loadMoreOnIndex =
rowsBeforeLoadMore > grid.rowCount || lastRow.index > grid.rowCount - rowsBeforeLoadMore
? grid.rowCount - 1
: grid.rowCount - rowsBeforeLoadMore;
if (lastRow.index === loadMoreOnIndex || lastRow.index > grid.rowCount) grid.onLoadMore();
}, [virtualRows, grid.rowCount, grid.rowsBeforeLoadMore, grid.onLoadMore, grid]);
if (lastRow.index >= loadMoreFromRow - 1) grid.onLoadMore();
}, [virtualRows, grid.rowCount, grid.onLoadMore, grid]);
useMutationObserver(scrollRef, () => setListOffset(ref.current?.offsetTop ?? 0));