Skip to content

Commit

Permalink
upd: make loading projects up to 3x faster
Browse files Browse the repository at this point in the history
  • Loading branch information
solvedDev committed Sep 8, 2022
1 parent 1738f9a commit a655429
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/components/Projects/ProjectManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,29 +96,37 @@ export class ProjectManager extends Signal<void> {
'projects',
{ create: true }
)
const localDirectoryHandle =
await this.app.fileSystem.getDirectoryHandle('~local/projects', {
create: true,
})

const isBridgeFolderSetup = this.app.bridgeFolderSetup.hasFired

const promises = []

// Load existing projects
for await (const handle of directoryHandle.values()) {
if (handle.kind !== 'directory') continue

await this.addProject(handle, false, requiresPermissions)
promises.push(this.addProject(handle, false, requiresPermissions))
}

if (isBridgeFolderSetup) {
const localDirectoryHandle =
await this.app.fileSystem.getDirectoryHandle(
'~local/projects',
{
create: true,
}
)

// Load local projects as well
for await (const handle of localDirectoryHandle.values()) {
if (handle.kind !== 'directory') continue

await this.addProject(handle, false, false)
promises.push(this.addProject(handle, false, false))
}
}

await Promise.allSettled(promises)

// Update stored projects
if (isBridgeFolderSetup) await this.storeProjects(undefined, true)
// Create a placeholder project (virtual project)
Expand Down

0 comments on commit a655429

Please sign in to comment.