From adbcfb0117cac28190d13d4948c8d63d55150c23 Mon Sep 17 00:00:00 2001 From: Drew Ansbacher Date: Mon, 27 Sep 2021 11:26:28 -0600 Subject: [PATCH] moved to service --- .../marketplace-list/marketplace-list.page.ts | 18 ++++-------------- .../marketplace-routes/marketplace.service.ts | 10 ++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.ts b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.ts index db024ebe7..78e2b5373 100644 --- a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.ts +++ b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.ts @@ -28,7 +28,6 @@ export class MarketplaceListPage { data: MarketplaceData eos: MarketplaceEOS - allPkgs: MarketplacePkg[] = [] pkgs: MarketplacePkg[] = [] PackageState = PackageState @@ -58,11 +57,12 @@ export class MarketplaceListPage { const [data, eos] = await Promise.all([ this.api.getMarketplaceData({ }), this.api.getEos({ }), - this.getAllPkgs(), + this.marketplaceService.getAllPkgs(), ]) this.eos = eos this.data = data + this.pkgsLoading = false this.getPkgs() // category should start as first item in array @@ -103,23 +103,13 @@ export class MarketplaceListPage { ) } - private async getAllPkgs (): Promise { - this.allPkgs = await this.marketplaceService.getPkgs( - undefined, - this.query, - 1, - 100000, - ) - this.pkgsLoading = false - } - private async getPkgs (): Promise { if (this.category === 'updates') { - this.pkgs = this.allPkgs.filter(pkg => { + this.pkgs = this.marketplaceService.allPkgs.filter(pkg => { return this.localPkgs[pkg.manifest.id] && pkg.manifest.version !== this.localPkgs[pkg.manifest.id].manifest.version }) } else { - this.pkgs = this.allPkgs.filter(pkg => { + this.pkgs = this.marketplaceService.allPkgs.filter(pkg => { if (this.query) { return pkg.manifest.id.toUpperCase().includes(this.query.toUpperCase()) || pkg.manifest.title.toUpperCase().includes(this.query.toUpperCase()) || diff --git a/ui/src/app/pages/marketplace-routes/marketplace.service.ts b/ui/src/app/pages/marketplace-routes/marketplace.service.ts index 5cfbd8647..f03e9f281 100644 --- a/ui/src/app/pages/marketplace-routes/marketplace.service.ts +++ b/ui/src/app/pages/marketplace-routes/marketplace.service.ts @@ -8,6 +8,7 @@ import { PackageDataEntry } from 'src/app/services/patch-db/data-model' providedIn: 'root', }) export class MarketplaceService { + allPkgs: MarketplacePkg[] = [] pkgs: { [id: string]: MarketplacePkg } = { } updates: MarketplacePkg[] = [] releaseNotes: { [id: string]: { @@ -34,6 +35,15 @@ export class MarketplaceService { this.updates = updates } + async getAllPkgs (): Promise { + this.allPkgs = await this.getPkgs( + undefined, + null, + 1, + 100000, + ) + } + async getPkgs (category: string, query: string, page: number, perPage: number) : Promise { const pkgs = await this.api.getMarketplacePkgs({ category: category !== 'all' ? category : undefined,