Skip to content

Commit

Permalink
fix: add disable for load more
Browse files Browse the repository at this point in the history
  • Loading branch information
asabotovich committed Mar 28, 2024
1 parent 5c115f3 commit 8d3095e
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/components/DashboardPage/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { FiltersPanel } from '../FiltersPanel/FiltersPanel';

import { tr } from './DashboardPage.i18n';

export const projectsLimit = 5;
export const projectsLimit = 3;

export const DashboardPage = ({ user, ssrTime, defaultPresetFallback }: ExternalPageProps) => {
const utils = trpc.useContext();
Expand All @@ -33,17 +33,18 @@ export const DashboardPage = ({ user, ssrTime, defaultPresetFallback }: External
preset,
});

const { data, isLoading, fetchNextPage, hasNextPage } = trpc.project.getUserProjectsWithGoals.useInfiniteQuery(
{
limit: projectsLimit,
goalsQuery: queryState,
},
{
getNextPageParam: (p) => p.nextCursor,
keepPreviousData: true,
staleTime: refreshInterval,
},
);
const { data, isLoading, isFetching, fetchNextPage, hasNextPage } =
trpc.project.getUserProjectsWithGoals.useInfiniteQuery(
{
limit: projectsLimit,
goalsQuery: queryState,
},
{
getNextPageParam: (p) => p.nextCursor,
keepPreviousData: true,
staleTime: refreshInterval,
},
);

const pages = useMemo(() => data?.pages || [], [data?.pages]);

Expand Down Expand Up @@ -125,7 +126,7 @@ export const DashboardPage = ({ user, ssrTime, defaultPresetFallback }: External
</ListView>

{nullable(hasNextPage, () => (
<LoadMoreButton onClick={fetchNextPage as () => void} />
<LoadMoreButton disabled={isFetching} onClick={fetchNextPage as () => void} />
))}

<PresetModals preset={preset} />
Expand Down

0 comments on commit 8d3095e

Please sign in to comment.