diff --git a/packages/insomnia/src/ui/routes/root.tsx b/packages/insomnia/src/ui/routes/root.tsx index 164d64040d..f3fa50507f 100644 --- a/packages/insomnia/src/ui/routes/root.tsx +++ b/packages/insomnia/src/ui/routes/root.tsx @@ -76,15 +76,20 @@ export interface RootLoaderData { organizations: Organization[]; settings: Settings; } - +// NOTE: when getVCS is rewritten to be less spaghetti +// this can be removed, and get team should only run once, +// at app start and whenever the user logs in +// This "workaround" will not work if a user logs out and back in again +let hasRun = false; export const loader: LoaderFunction = async (): Promise => { // Load all projects try { const vcs = getVCS(); - if (vcs && isLoggedIn()) { + if (vcs && isLoggedIn() && !hasRun) { const teams = await vcs.teams(); const projects = await Promise.all(teams.map(initializeProjectFromTeam)); await database.batchModifyDocs({ upsert: projects }); + hasRun = true; } } catch { console.log('Failed to load projects');