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

View File

@@ -3,10 +3,18 @@ import {
DataModel, DataModel,
UIMarketplaceData, UIMarketplaceData,
} from 'src/app/services/patch-db/data-model' } from 'src/app/services/patch-db/data-model'
import { filter, firstValueFrom } from 'rxjs' import { filter, firstValueFrom, startWith } from 'rxjs'
export function getMarketplace( export function getMarketplace(
patch: PatchDB<DataModel>, patch: PatchDB<DataModel>,
): Promise<UIMarketplaceData> { ): 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': {},
}),
),
)
} }