From bec4e8224f6cb16671bec97485eae4bf71a9b27b Mon Sep 17 00:00:00 2001 From: Jack Kavanagh Date: Fri, 18 Aug 2023 14:53:24 +0200 Subject: [PATCH] hasrun (#6325) * hasrun * better comment (filipe) --- packages/insomnia/src/ui/routes/root.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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');