Skip to content

Commit

Permalink
Bugfix/marketplace add (#1805)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
elvece and MattDHill authored Sep 15, 2022
1 parent e326c5b commit 5346307
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
11 changes: 8 additions & 3 deletions frontend/projects/ui/src/app/services/marketplace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand Down Expand Up @@ -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
}
Expand Down
12 changes: 10 additions & 2 deletions frontend/projects/ui/src/app/util/get-marketplace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': {},
}),
),
)
}

0 comments on commit 5346307

Please sign in to comment.