Skip to content

Commit 806d6a4

Browse files
committed
fix: indexing modal now tracks last successful repo, not last in array
Reference equality check (repo === githubRepos[last]) meant if the last repo errored, the modal never opened for earlier successes. Now tracks lastSuccessId/lastSuccessName and opens modal after the loop.
1 parent b62b5b8 commit 806d6a4

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

frontend/src/components/dashboard/DashboardHome.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,17 @@ export function DashboardHome() {
107107
const handleGitHubImport = async (githubRepos: GitHubRepo[]) => {
108108
if (githubRepos.length === 0) return
109109

110+
let lastSuccessId: string | null = null
111+
let lastSuccessName = ''
112+
110113
for (const repo of githubRepos) {
111114
try {
112115
setLoading(true)
113116
const repoId = await addAndIndex(repo.name, repo.clone_url, repo.default_branch)
114117

115118
if (repoId) {
116-
if (repo === githubRepos[githubRepos.length - 1]) {
117-
setIndexingRepoId(repoId)
118-
setIndexingRepoName(repo.name)
119-
setShowIndexingModal(true)
120-
}
119+
lastSuccessId = repoId
120+
lastSuccessName = repo.name
121121
toast.success(`Added ${repo.name}`)
122122
}
123123
} catch (error) {
@@ -127,6 +127,13 @@ export function DashboardHome() {
127127
}
128128
}
129129

130+
// show indexing modal for the last successfully added repo
131+
if (lastSuccessId) {
132+
setIndexingRepoId(lastSuccessId)
133+
setIndexingRepoName(lastSuccessName)
134+
setShowIndexingModal(true)
135+
}
136+
130137
setLoading(false)
131138
refreshRepos()
132139
}

0 commit comments

Comments
 (0)