moved to service

This commit is contained in:
Drew Ansbacher
2021-09-27 11:26:28 -06:00
committed by Aiden McClelland
parent 9fb0f80ba8
commit adbcfb0117
2 changed files with 14 additions and 14 deletions

View File

@@ -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<void> {
this.allPkgs = await this.marketplaceService.getPkgs(
undefined,
this.query,
1,
100000,
)
this.pkgsLoading = false
}
private async getPkgs (): Promise<void> {
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()) ||

View File

@@ -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<void> {
this.allPkgs = await this.getPkgs(
undefined,
null,
1,
100000,
)
}
async getPkgs (category: string, query: string, page: number, perPage: number) : Promise<MarketplacePkg[]> {
const pkgs = await this.api.getMarketplacePkgs({
category: category !== 'all' ? category : undefined,