mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
market cancel http sub
This commit is contained in:
committed by
Aiden McClelland
parent
7178e82ff5
commit
7320abf317
@@ -4,11 +4,12 @@ import { wizardModal } from 'src/app/components/install-wizard/install-wizard.co
|
|||||||
import { IonContent, ModalController } from '@ionic/angular'
|
import { IonContent, ModalController } from '@ionic/angular'
|
||||||
import { WizardBaker } from 'src/app/components/install-wizard/prebaked-wizards'
|
import { WizardBaker } from 'src/app/components/install-wizard/prebaked-wizards'
|
||||||
import { PackageDataEntry, PackageState } from 'src/app/services/patch-db/data-model'
|
import { PackageDataEntry, PackageState } from 'src/app/services/patch-db/data-model'
|
||||||
import { Subscription } from 'rxjs'
|
import { defer, Subscription } from 'rxjs'
|
||||||
import { ErrorToastService } from 'src/app/services/error-toast.service'
|
import { ErrorToastService } from 'src/app/services/error-toast.service'
|
||||||
import { MarketplaceService } from '../marketplace.service'
|
import { MarketplaceService } from '../marketplace.service'
|
||||||
import { ApiService } from 'src/app/services/api/embassy-api.service'
|
import { ApiService } from 'src/app/services/api/embassy-api.service'
|
||||||
import { PatchDbService } from 'src/app/services/patch-db/patch-db.service'
|
import { PatchDbService } from 'src/app/services/patch-db/patch-db.service'
|
||||||
|
import { catchError, finalize, take } from 'rxjs/operators'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'marketplace-list',
|
selector: 'marketplace-list',
|
||||||
@@ -36,6 +37,7 @@ export class MarketplaceListPage {
|
|||||||
readonly perPage = 30
|
readonly perPage = 30
|
||||||
|
|
||||||
subs: Subscription[] = []
|
subs: Subscription[] = []
|
||||||
|
searchSub: Subscription
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private readonly marketplaceService: MarketplaceService,
|
private readonly marketplaceService: MarketplaceService,
|
||||||
@@ -74,7 +76,6 @@ export class MarketplaceListPage {
|
|||||||
this.errToast.present(e)
|
this.errToast.present(e)
|
||||||
} finally {
|
} finally {
|
||||||
this.pageLoading = false
|
this.pageLoading = false
|
||||||
this.pkgsLoading = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,29 +112,34 @@ export class MarketplaceListPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getPkgs (doInfinite = false): Promise<void> {
|
private async getPkgs (doInfinite = false): Promise<void> {
|
||||||
try {
|
if (this.searchSub) this.searchSub.unsubscribe()
|
||||||
if (this.category === 'updates') {
|
|
||||||
this.pkgs = this.marketplaceService.updates
|
if (this.category === 'updates') {
|
||||||
if (this.pkgs.length) {
|
this.pkgs = this.marketplaceService.updates
|
||||||
this.pkgsLoading = false
|
if (this.pkgs.length) {
|
||||||
}
|
this.pkgsLoading = false
|
||||||
await this.marketplaceService.getUpdates(this.localPkgs)
|
|
||||||
this.pkgs = this.marketplaceService.updates
|
|
||||||
} else {
|
|
||||||
const pkgs = await this.marketplaceService.getPkgs(
|
|
||||||
this.category !== 'all' ? this.category : undefined,
|
|
||||||
this.query,
|
|
||||||
this.page,
|
|
||||||
this.perPage,
|
|
||||||
)
|
|
||||||
this.needInfinite = pkgs.length >= this.perPage
|
|
||||||
this.page++
|
|
||||||
this.pkgs = doInfinite ? this.pkgs.concat(pkgs) : pkgs
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
this.searchSub = defer(() => this.marketplaceService.getUpdates(this.localPkgs))
|
||||||
this.errToast.present(e)
|
.pipe(take(1), catchError(e => this.errToast.present(e)))
|
||||||
} finally {
|
.subscribe(_ => {
|
||||||
this.pkgsLoading = false
|
this.pkgs = this.marketplaceService.updates
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.searchSub = defer(() => this.marketplaceService.getPkgs(
|
||||||
|
this.category !== 'all' ? this.category : undefined,
|
||||||
|
this.query,
|
||||||
|
this.page,
|
||||||
|
this.perPage,
|
||||||
|
))
|
||||||
|
.pipe(take(1), catchError(e => this.errToast.present(e)))
|
||||||
|
.subscribe(pkgs => {
|
||||||
|
if (pkgs) {
|
||||||
|
this.needInfinite = pkgs.length >= this.perPage
|
||||||
|
this.page++
|
||||||
|
this.pkgs = doInfinite ? this.pkgs.concat(pkgs) : pkgs
|
||||||
|
}
|
||||||
|
this.pkgsLoading = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user