From 953f1d0b2fc4ec0001392dfe4bb12a70525f9707 Mon Sep 17 00:00:00 2001 From: Jan Keromnes Date: Fri, 8 Oct 2021 11:19:19 +0200 Subject: [PATCH] [projects] Load the last prebuilds of all projects in parallel --- .../dashboard/src/projects/Projects.tsx | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/components/dashboard/src/projects/Projects.tsx b/components/dashboard/src/projects/Projects.tsx index 4649b7a0450e1e..e68ef0f20f8a5e 100644 --- a/components/dashboard/src/projects/Projects.tsx +++ b/components/dashboard/src/projects/Projects.tsx @@ -45,15 +45,21 @@ export default function () { : await getGitpodService().server.getUserProjects()); setProjects(infos); - for (const p of infos) { - const lastPrebuild = await getGitpodService().server.findPrebuilds({ - projectId: p.id, - latest: true, - }); - if (lastPrebuild[0]) { - setLastPrebuilds(prev => new Map(prev).set(p.id, lastPrebuild[0])); + const map = new Map(); + await Promise.all(infos.map(async (p) => { + try { + const lastPrebuild = await getGitpodService().server.findPrebuilds({ + projectId: p.id, + latest: true, + }); + if (lastPrebuild[0]) { + map.set(p.id, lastPrebuild[0]); + } + } catch (error) { + console.error('Failed to load prebuilds for project', p, error); } - } + })); + setLastPrebuilds(map); } const newProjectUrl = !!team ? `/new?team=${team.slug}` : '/new'; @@ -175,4 +181,4 @@ export default function () { )} ; -} \ No newline at end of file +}