mirror of
https://github.com/Kong/insomnia.git
synced 2026-04-22 15:18:27 -04:00
@@ -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<RootLoaderData> => {
|
||||
// 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');
|
||||
|
||||
Reference in New Issue
Block a user