Skip to content

Commit

Permalink
Fix loading state bug when creating new workspace (#18870)
Browse files Browse the repository at this point in the history
* fixing bug with multiple projects per repo in selector when searching

* remove optionsLoaded for loading state check
  • Loading branch information
selfcontained authored Oct 5, 2023
1 parent 07597d5 commit 75f4c29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 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
4 changes: 2 additions & 2 deletions components/dashboard/src/workspaces/CreateWorkspacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export function CreateWorkspacePage() {
selectedIdeOption={selectedIde}
useLatest={useLatestIde}
disabled={createWorkspaceMutation.isStarting}
loading={workspaceContext.isLoading || !optionsLoaded}
loading={workspaceContext.isLoading}
/>
</InputField>

Expand All @@ -408,7 +408,7 @@ export function CreateWorkspacePage() {
setError={setErrorWsClass}
selectedWorkspaceClass={selectedWsClass}
disabled={createWorkspaceMutation.isStarting}
loading={workspaceContext.isLoading || !optionsLoaded}
loading={workspaceContext.isLoading}
/>
</InputField>
</div>
Expand Down

0 comments on commit 75f4c29

Please sign in to comment.