Skip to content

Commit

Permalink
fixing bug with multiple projects per repo in selector when searching
Browse files Browse the repository at this point in the history
  • Loading branch information
selfcontained committed Oct 4, 2023
1 parent 07597d5 commit 696e1c2
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ export const useUnifiedRepositorySearch = ({ searchString }: { searchString: str
const searchQuery = useSearchRepositories({ searchString });

const filteredRepos = useMemo(() => {
const repoMap = new Map<string, SuggestedRepository>((suggestedQuery.data || []).map((r) => [r.url, r]));
const repoMap = new Map<string, SuggestedRepository>(
(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);
}
}

Expand Down

0 comments on commit 696e1c2

Please sign in to comment.