fix(app): register new home projects (#41018)
This commit is contained in:
@@ -90,7 +90,20 @@ export function createHomeController() {
|
||||
const directory = directories[0]
|
||||
if (!directory) return
|
||||
const ctx = global.ensureServerCtx(conn)
|
||||
directories.forEach((item) => ctx.projects.open(item))
|
||||
directories.forEach((item) => {
|
||||
if (ctx.projects.list().some((project) => project.worktree === item)) return
|
||||
const location = { directory: item }
|
||||
void ctx.sdk.api.file
|
||||
.list({ path: ".", location })
|
||||
.then(async (files) => {
|
||||
if (files.data.length > 0) return ctx.sdk.api.project.current({ location })
|
||||
const result = await ctx.sdk.client.project.initGit({ directory: item })
|
||||
return result.data ?? ctx.sdk.api.project.current({ location })
|
||||
})
|
||||
.then((project) => ctx.sync.child(item, { bootstrap: false })[1]("project", project.id))
|
||||
.catch(() => undefined)
|
||||
ctx.projects.open(item)
|
||||
})
|
||||
ctx.projects.touch(directory)
|
||||
setSelection({ server: ServerConnection.key(conn), directory })
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user