mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
fix mrketplace swtiching (#1810)
This commit is contained in:
@@ -65,7 +65,9 @@ export class AppConfigPage {
|
||||
|
||||
async ngOnInit() {
|
||||
try {
|
||||
this.pkg = await getPackage(this.patch, this.pkgId)
|
||||
const pkg = await getPackage(this.patch, this.pkgId)
|
||||
if (!pkg) return
|
||||
this.pkg = pkg
|
||||
|
||||
if (!this.pkg.manifest.config) return
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ export class AppInterfacesPage {
|
||||
|
||||
async ngOnInit() {
|
||||
const pkg = await getPackage(this.patch, this.pkgId)
|
||||
if (!pkg) return
|
||||
|
||||
const interfaces = pkg.manifest.interfaces
|
||||
const uiKey = getUiInterfaceKey(interfaces)
|
||||
|
||||
|
||||
@@ -117,7 +117,6 @@ export class MarketplacesPage {
|
||||
async presentAction(id: string | null) {
|
||||
// no need to view actions if is selected marketplace
|
||||
const marketplace = await getMarketplace(this.patch)
|
||||
|
||||
if (id === marketplace['selected-id']) return
|
||||
|
||||
const buttons: ActionSheetButton[] = [
|
||||
|
||||
@@ -37,11 +37,13 @@ export class MarketplaceService extends AbstractMarketplaceService {
|
||||
private readonly uiMarketplaceData$ = this.patch
|
||||
.watch$('ui', 'marketplace')
|
||||
.pipe(
|
||||
filter(Boolean),
|
||||
startWith({
|
||||
'selected-id': null,
|
||||
'known-hosts': {},
|
||||
}),
|
||||
map(
|
||||
m =>
|
||||
m || {
|
||||
'selected-id': null,
|
||||
'known-hosts': {},
|
||||
},
|
||||
),
|
||||
distinctUntilChanged(
|
||||
(prev, curr) => prev['selected-id'] === curr['selected-id'],
|
||||
),
|
||||
|
||||
@@ -3,18 +3,20 @@ import {
|
||||
DataModel,
|
||||
UIMarketplaceData,
|
||||
} from 'src/app/services/patch-db/data-model'
|
||||
import { filter, firstValueFrom, startWith } from 'rxjs'
|
||||
import { firstValueFrom, map } from 'rxjs'
|
||||
|
||||
export function getMarketplace(
|
||||
patch: PatchDB<DataModel>,
|
||||
): Promise<UIMarketplaceData> {
|
||||
return firstValueFrom(
|
||||
patch.watch$('ui', 'marketplace').pipe(
|
||||
filter(Boolean),
|
||||
startWith({
|
||||
'selected-id': null,
|
||||
'known-hosts': {},
|
||||
}),
|
||||
map(
|
||||
m =>
|
||||
m || {
|
||||
'selected-id': null,
|
||||
'known-hosts': {},
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { filter, firstValueFrom } from 'rxjs'
|
||||
export function getPackage(
|
||||
patch: PatchDB<DataModel>,
|
||||
id: string,
|
||||
): Promise<PackageDataEntry> {
|
||||
): Promise<PackageDataEntry | undefined> {
|
||||
return firstValueFrom(patch.watch$('package-data', id))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user