Bugfix/marketplace add (#1805)

* remove falsey check when getting marketplaces, as no alts could exist

* filter boolean but start with object

Co-authored-by: Matt Hill <matthewonthemoon@gmail.com>
This commit is contained in:
Lucy C
2022-09-15 13:30:49 -06:00
committed by GitHub
parent e326c5be4a
commit 53463077df
2 changed files with 18 additions and 5 deletions

View File

@@ -37,8 +37,13 @@ export class MarketplaceService extends AbstractMarketplaceService {
private readonly uiMarketplaceData$ = this.patch
.watch$('ui', 'marketplace')
.pipe(
filter(Boolean),
startWith({
'selected-id': null,
'known-hosts': {},
}),
distinctUntilChanged(
(prev, curr) => prev?.['selected-id'] === curr?.['selected-id'],
(prev, curr) => prev['selected-id'] === curr['selected-id'],
),
shareReplay(1),
)
@@ -280,8 +285,8 @@ export class MarketplaceService extends AbstractMarketplaceService {
}
}
private toMarketplace(marketplace?: UIMarketplaceData): Marketplace {
return marketplace?.['selected-id']
private toMarketplace(marketplace: UIMarketplaceData): Marketplace {
return marketplace['selected-id']
? marketplace['known-hosts'][marketplace['selected-id']]
: this.config.marketplace
}

View File

@@ -3,10 +3,18 @@ import {
DataModel,
UIMarketplaceData,
} from 'src/app/services/patch-db/data-model'
import { filter, firstValueFrom } from 'rxjs'
import { filter, firstValueFrom, startWith } from 'rxjs'
export function getMarketplace(
patch: PatchDB<DataModel>,
): Promise<UIMarketplaceData> {
return firstValueFrom(patch.watch$('ui', 'marketplace').pipe(filter(Boolean)))
return firstValueFrom(
patch.watch$('ui', 'marketplace').pipe(
filter(Boolean),
startWith({
'selected-id': null,
'known-hosts': {},
}),
),
)
}