From 4bde212eef5ea07b76b4e25b37eb73e7d381d03b Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Wed, 11 Oct 2023 14:33:06 -0500 Subject: [PATCH] fix: add check for listId to hooks (#1869) --- lib/hooks/api/useContributionsByProject.ts | 2 +- lib/hooks/api/useContributorList.ts | 2 +- lib/hooks/api/useContributorsByProject.ts | 2 +- lib/hooks/api/useMostActiveContributors.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/hooks/api/useContributionsByProject.ts b/lib/hooks/api/useContributionsByProject.ts index bc44b9f62d..e43fcaa525 100644 --- a/lib/hooks/api/useContributionsByProject.ts +++ b/lib/hooks/api/useContributionsByProject.ts @@ -11,7 +11,7 @@ export const useContributionsByProject = ({ initialData?: DbProjectContributions[]; }) => { const { data, error } = useSWR( - `lists/${listId}/stats/contributions-by-project?range=${range}`, + listId ? `lists/${listId}/stats/contributions-by-project?range=${range}` : null, publicApiFetcher as Fetcher // { // fallbackData: { diff --git a/lib/hooks/api/useContributorList.ts b/lib/hooks/api/useContributorList.ts index cfb46e45f3..24144ce99d 100644 --- a/lib/hooks/api/useContributorList.ts +++ b/lib/hooks/api/useContributorList.ts @@ -42,7 +42,7 @@ export const useContributorsList = ({ query.append("range", range.toString()); const { data, error, mutate } = useSWR( - `lists/${listId}/contributors?${query}`, + listId ? `lists/${listId}/contributors?${query}` : null, publicApiFetcher as Fetcher, Error>, { fallbackData: initialData, diff --git a/lib/hooks/api/useContributorsByProject.ts b/lib/hooks/api/useContributorsByProject.ts index 18677a0214..b7883ced0f 100644 --- a/lib/hooks/api/useContributorsByProject.ts +++ b/lib/hooks/api/useContributorsByProject.ts @@ -5,7 +5,7 @@ import publicApiFetcher from "lib/utils/public-api-fetcher"; export const useContributorsByProject = (listId: string, range: number) => { const [repoId, setRepoId] = useState(null); const { data, error } = useSWR( - `lists/${listId}/stats/top-project-contributions-by-contributor?repo_id=${repoId}&range=${range}`, + listId ? `lists/${listId}/stats/top-project-contributions-by-contributor?repo_id=${repoId}&range=${range}` : null, publicApiFetcher as Fetcher ); diff --git a/lib/hooks/api/useMostActiveContributors.ts b/lib/hooks/api/useMostActiveContributors.ts index d3f998e407..dc276aef02 100644 --- a/lib/hooks/api/useMostActiveContributors.ts +++ b/lib/hooks/api/useMostActiveContributors.ts @@ -43,7 +43,7 @@ const useMostActiveContributors = ({ const apiEndpoint = `lists/${listId}/stats/most-active-contributors?${query.toString()}`; const { data, error, mutate } = useSWR( - apiEndpoint, + listId ? apiEndpoint : null, publicApiFetcher as Fetcher );