Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/id params #1414

Merged
merged 5 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion frontend/projects/ui/src/app/services/api/api.fixures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ export module Mock {
}
} = {
bitcoind: {
'0.19.2': {
'0.19.0': {
icon: BTC_ICON,
license: 'licenseUrl',
instructions: 'instructionsUrl',
Expand Down
15 changes: 15 additions & 0 deletions frontend/projects/ui/src/app/services/api/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
6 changes: 5 additions & 1 deletion frontend/projects/ui/src/app/services/marketplace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
shareReplay,
startWith,
switchMap,
take,
tap,
} from 'rxjs/operators'

Expand All @@ -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)),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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,
Expand Down