From 14519ef5559038b0d9d037a2bdc5d98e63c9db6f Mon Sep 17 00:00:00 2001 From: Brandon Cohen Date: Fri, 13 May 2022 15:15:53 -0400 Subject: [PATCH] fix(recommendations): only load more titles if there can be more than 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 --- src/hooks/useDiscover.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hooks/useDiscover.ts b/src/hooks/useDiscover.ts index 24ba47c1e..3bc016eb2 100644 --- a/src/hooks/useDiscover.ts +++ b/src/hooks/useDiscover.ts @@ -82,7 +82,9 @@ const useDiscover = >( 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,