Skip to content

Commit

Permalink
feat: only tag maintainers for the specific repo on repo pages (#3395)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts committed May 15, 2024
1 parent 2c87813 commit 54c9a93
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 7 additions & 3 deletions components/organisms/ContributorCard/contributor-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ const ContributorCard = ({ className, contributor, topic, repositories, range }:
const githubAvatar = getAvatarByUsername(contributor.author_login);
const { repoList, meta } = useContributorPullRequestsChart(contributor.author_login, topic, repositories, range);
const languageList = useContributorLanguages(contributor.author_login);
const { data: user } = useFetchUser(contributor.author_login, {
revalidateOnFocus: false,
});
const { data: user } = useFetchUser(
contributor.author_login,
{
revalidateOnFocus: false,
},
repositories
);

const { is_maintainer: isMaintainer } = user ?? {};

Expand Down
10 changes: 8 additions & 2 deletions lib/hooks/useFetchUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ import { publicApiFetcher } from "lib/utils/public-api-fetcher";

type UserResponse = DbUser;

const useFetchUser = (username: string, config?: SWRConfiguration) => {
const useFetchUser = (username: string, config?: SWRConfiguration, repositories?: number[]) => {
const query = new URLSearchParams();

if (repositories) {
query.set("maintainerRepoIds", repositories.join(","));
}

const { data, error, mutate } = useSWR<UserResponse, Error>(
username ? `users/${username}` : null,
username ? `users/${username}?${query}` : null,
publicApiFetcher as Fetcher<UserResponse, Error>,
config
);
Expand Down

0 comments on commit 54c9a93

Please sign in to comment.