Skip to content

Commit

Permalink
fix(recommendations): fixed recommendations page causing infinite net…
Browse files Browse the repository at this point in the history
…work 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. A limit was implemented to specifically to solve this
problem
  • Loading branch information
OwsleyJr authored and Fallenbagel committed May 21, 2022
1 parent b07f703 commit 4f972be
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 4f972be

Please sign in to comment.