From 696e1c2952ca87145c1c9543eabf5a674e6c1475 Mon Sep 17 00:00:00 2001 From: Brad Harris Date: Wed, 4 Oct 2023 21:47:29 +0000 Subject: [PATCH] fixing bug with multiple projects per repo in selector when searching --- .../git-providers/unified-repositories-search-query.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/dashboard/src/data/git-providers/unified-repositories-search-query.ts b/components/dashboard/src/data/git-providers/unified-repositories-search-query.ts index 86fe1386cc10e7..b2ae500f7369eb 100644 --- a/components/dashboard/src/data/git-providers/unified-repositories-search-query.ts +++ b/components/dashboard/src/data/git-providers/unified-repositories-search-query.ts @@ -15,12 +15,16 @@ export const useUnifiedRepositorySearch = ({ searchString }: { searchString: str const searchQuery = useSearchRepositories({ searchString }); const filteredRepos = useMemo(() => { - const repoMap = new Map((suggestedQuery.data || []).map((r) => [r.url, r])); + const repoMap = new Map( + (suggestedQuery.data || []).map((r) => [`${r.url}:${r.projectId || ""}`, r]), + ); // Merge the search results into the suggested results for (const repo of searchQuery.data || []) { - if (!repoMap.has(repo.url)) { - repoMap.set(repo.url, repo); + const key = `${repo.url}:${repo.projectId || ""}`; + + if (!repoMap.has(key)) { + repoMap.set(key, repo); } }