Skip to content

Commit

Permalink
Lazy load categories and marketplaceVersion (#16258)
Browse files Browse the repository at this point in the history
Co-authored-by: Douglas Gubert <d-gubert@users.noreply.github.com>
  • Loading branch information
Shiqi Mei and d-gubert authored Feb 28, 2020
1 parent dbc774a commit 8771184
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
22 changes: 10 additions & 12 deletions app/apps/client/admin/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,25 @@ Template.apps.onCreated(function() {

(async () => {
try {
const appsFromMarketplace = await Apps.getAppsFromMarketplace().catch(() => []);
const installedApps = await Apps.getApps();
let apps = installedApps.map((app) => ({ ...app, installed: true }));

this.state.set('apps', apps);

const appsFromMarketplace = await Apps.getAppsFromMarketplace().catch(() => []);

const apps = installedApps.map((app) => {
apps = apps.map((app) => {
const appFromMarketplace = appsFromMarketplace.find(({ id } = {}) => id === app.id);

if (!appFromMarketplace) {
if (appFromMarketplace) {
return {
...app,
installed: true,
categories: appFromMarketplace.categories,
marketplaceVersion: appFromMarketplace.version,
};
}

return {
...app,
installed: true,
categories: appFromMarketplace.categories,
marketplaceVersion: appFromMarketplace.version,
};
return app;
});

this.state.set('apps', apps);
} catch (error) {
handleAPIError(error);
Expand Down
10 changes: 6 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8771184

Please sign in to comment.