fix mrketplace swtiching (#1810)

This commit is contained in:
Matt Hill
2022-09-19 12:59:29 -06:00
committed by GitHub
parent 53463077df
commit f04b90d9c6
6 changed files with 21 additions and 14 deletions

View File

@@ -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': {},
},
),
),
)
}

View File

@@ -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))
}