Skip to content

Commit

Permalink
[projects] Load the last prebuilds of all projects in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
jankeromnes authored and roboquat committed Oct 8, 2021
1 parent bdf1127 commit 953f1d0
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions components/dashboard/src/projects/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -175,4 +181,4 @@ export default function () {
</div>
)}
</>;
}
}

0 comments on commit 953f1d0

Please sign in to comment.