Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/containers/Operations/useOperationsInfiniteQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import {throttle} from 'lodash';

import {operationsApi} from '../../store/reducers/operations';
import {DEFAULT_PAGE_SIZE, operationsApi} from '../../store/reducers/operations';
import type {OperationKind} from '../../types/api/operations';

interface UseOperationsInfiniteQueryProps {
Expand All @@ -18,7 +18,7 @@ const DEFAULT_SCROLL_MARGIN = 100;
export function useOperationsInfiniteQuery({
database,
kind,
pageSize = 10,
pageSize = DEFAULT_PAGE_SIZE,
searchValue,
scrollContainerRef,
}: UseOperationsInfiniteQueryProps) {
Expand Down Expand Up @@ -63,8 +63,14 @@ export function useOperationsInfiniteQuery({
// Check after data updates
React.useLayoutEffect(() => {
if (!isFetchingNextPage) {
checkAndLoadMorePages();
// RAF to ensure browser has completed layout and paint
const raf = requestAnimationFrame(() => {
checkAndLoadMorePages();
});
return () => cancelAnimationFrame(raf);
}

return undefined;
Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The explicit return undefined; at the end of the effect is redundant, as React effects without a cleanup implicitly return undefined. You can remove it to simplify the code.

Suggested change
return undefined;

Copilot uses AI. Check for mistakes.
}, [data, isFetchingNextPage, checkAndLoadMorePages]);

// Scroll handler for infinite scrolling
Expand Down
2 changes: 1 addition & 1 deletion src/store/reducers/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {

import {api} from './api';

const DEFAULT_PAGE_SIZE = 20;
export const DEFAULT_PAGE_SIZE = 20;

// Validate and normalize the response to ensure it has proper structure
function validateOperationListResponse(data: TOperationList): TOperationList {
Expand Down
Loading