Fix/id params (#1414)

* watch config.json for changes when just building frontend

* fix version for data consistency

* clone param ids so not recursively stringified; add global type for stringified instances

* ensure only most recent data source grabbed to fix issue with service auto update on marketplace switch

* use take instead of shallow cloning data
This commit is contained in:
Lucy C
2022-05-10 12:20:32 -06:00
committed by GitHub
parent cc6cbbfb07
commit 8cf000198f
4 changed files with 22 additions and 3 deletions

View File

@@ -71,4 +71,4 @@ patch-db/client/dist: $(PATCH_DB_CLIENT_SRC) patch-db/client/node_modules
npm --prefix patch-db/client run build
# this is a convenience step to build all frontends - it is not referenced elsewhere in this file
frontend: frontend/node_modules $(EMBASSY_UIS)
frontend: frontend/node_modules frontend/config.json $(EMBASSY_UIS)

View File

@@ -610,7 +610,7 @@ export module Mock {
}
} = {
bitcoind: {
'0.19.2': {
'0.19.0': {
icon: BTC_ICON,
license: 'licenseUrl',
instructions: 'instructionsUrl',

View File

@@ -472,3 +472,18 @@ export interface AvailableWifi {
strength: number
security: string[]
}
declare global {
type Stringified<T> = string & {
[P in keyof T]: T[P]
}
interface JSON {
stringify<T>(
value: T,
replacer?: (key: string, value: any) => any,
space?: string | number,
): string & Stringified<T>
parse<T>(text: Stringified<T>, reviver?: (key: any, value: any) => any): T
}
}

View File

@@ -19,6 +19,7 @@ import {
shareReplay,
startWith,
switchMap,
take,
tap,
} from 'rxjs/operators'
@@ -45,6 +46,7 @@ export class MarketplaceService extends AbstractMarketplaceService {
)
private readonly pkg$: Observable<MarketplacePkg[]> = this.init$.pipe(
take(1),
switchMap(({ url, name }) =>
from(this.getMarketplacePkgs({ page: 1, 'per-page': 100 }, url)).pipe(
tap(() => this.onPackages(name)),
@@ -80,6 +82,7 @@ export class MarketplaceService extends AbstractMarketplaceService {
getPackage(id: string, version: string): Observable<MarketplacePkg> {
const params = { ids: [{ id, version }] }
const fallback$ = this.init$.pipe(
take(1),
switchMap(({ url }) => from(this.getMarketplacePkgs(params, url))),
map(pkgs => this.findPackage(pkgs, id, version)),
startWith(null),
@@ -135,6 +138,7 @@ export class MarketplaceService extends AbstractMarketplaceService {
req: Omit<RR.InstallPackageReq, 'marketplace-url'>,
): Observable<unknown> {
return this.getMarketplace().pipe(
take(1),
switchMap(({ url }) =>
from(
this.api.installPackage({
@@ -172,7 +176,7 @@ export class MarketplaceService extends AbstractMarketplaceService {
url: string,
): Promise<RR.GetMarketplacePackagesRes> {
if (params.query) delete params.category
if (params.ids) params.ids = JSON.stringify(params.ids) as any
if (params.ids) params.ids = JSON.stringify(params.ids)
const qp: RR.GetMarketplacePackagesReq = {
...params,