Skip to content

Commit

Permalink
fix(recommendations): only load more titles if there can be more than…
Browse files Browse the repository at this point in the history
… 40 (#2749)

* fix: fixed recommendations page causing infinite network requests to tmdb api

TMDB API would only return 40 results and the recommendations page expected more. This would cause
an infinite amount of network requests. I set a limit specifically for this solving the problem.

fix #2710
  • Loading branch information
OwsleyJr committed May 13, 2022
1 parent 1054b4e commit 14519ef
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/hooks/useDiscover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ const useDiscover = <T extends BaseMedia, S = Record<string, never>>(

const isEmpty = !isLoadingInitialData && titles?.length === 0;
const isReachingEnd =
isEmpty || (!!data && (data[data?.length - 1]?.results.length ?? 0) < 20);
isEmpty ||
(!!data && (data[data?.length - 1]?.results.length ?? 0) < 20) ||
(!!data && (data[data?.length - 1]?.totalResults ?? 0) < 41);

return {
isLoadingInitialData,
Expand Down

0 comments on commit 14519ef

Please sign in to comment.