Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Apps] Lazy load categories and marketplaceVersion in admin - apps page #16258

Merged
merged 2 commits into from
Feb 28, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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