diff options
Diffstat (limited to 'packages/web-util')
-rw-r--r-- | packages/web-util/src/context/activity.ts | 2 | ||||
-rw-r--r-- | packages/web-util/src/context/merchant-api.ts | 34 |
2 files changed, 13 insertions, 23 deletions
diff --git a/packages/web-util/src/context/activity.ts b/packages/web-util/src/context/activity.ts index 9a16f6673..422b25909 100644 --- a/packages/web-util/src/context/activity.ts +++ b/packages/web-util/src/context/activity.ts @@ -26,7 +26,7 @@ export class ActiviyTracker<Event> { this.notify = this.notify.bind(this) this.subscribe = this.subscribe.bind(this) } - notify(data: Event) { + notify(data: Event): void { this.observers.forEach((observer) => observer(data)) } subscribe(func: Listener<Event>): Unsuscriber { diff --git a/packages/web-util/src/context/merchant-api.ts b/packages/web-util/src/context/merchant-api.ts index 9998b3aeb..03c95d48e 100644 --- a/packages/web-util/src/context/merchant-api.ts +++ b/packages/web-util/src/context/merchant-api.ts @@ -69,7 +69,9 @@ enum VersionHint { } type Evictors = { - management?: CacheEvictor<TalerMerchantManagementCacheEviction | TalerMerchantInstanceCacheEviction>; + management?: CacheEvictor< + TalerMerchantManagementCacheEviction | TalerMerchantInstanceCacheEviction + >; }; type ConfigResult<T> = @@ -81,7 +83,7 @@ export type ConfigResultFail<T> = | { type: "incompatible"; result: T; supported: string } | { type: "error"; error: TalerError }; -const CONFIG_FAIL_TRY_AGAIN_MS = 5000 +const CONFIG_FAIL_TRY_AGAIN_MS = 5000; export const MerchantApiProvider = ({ baseUrl, @@ -108,7 +110,7 @@ export const MerchantApiProvider = ({ let keepRetrying = true; async function testConfig(): Promise<void> { try { - const config = await getRemoteConfig(); + const config = await getRemoteConfig(); if (LibtoolVersion.compare(VERSION, config.version)) { setChecked({ type: "ok", config, hints: [] }); } else { @@ -122,7 +124,7 @@ export const MerchantApiProvider = ({ if (error instanceof TalerError) { if (keepRetrying) { setTimeout(() => { - testConfig() + testConfig(); }, CONFIG_FAIL_TRY_AGAIN_MS); } setChecked({ type: "error", error }); @@ -135,7 +137,7 @@ export const MerchantApiProvider = ({ return () => { // on unload, stop retry keepRetrying = false; - } + }; }, []); if (!checked || checked.type !== "ok") { @@ -183,30 +185,18 @@ function buildMerchantApiClient( httpLib, ); - // const instance = (instanceId: string): TalerMerchantInstanceHttpClient => { - // return new TalerMerchantInstanceHttpClient( - // management.getSubInstanceAPI(instanceId).href, - // httpLib, - // evictors.instance ? evictors.instance(instanceId) : undefined, - // ); - // } - // const impersonate = (instanceId: string): TalerAuthenticationHttpClient => { - // return new TalerAuthenticationHttpClient( - // instance(instanceId).getAuthenticationAPI().href, - // httpLib, - // ); - // } - const rootUrl = url; function getSubInstanceAPI(instanceId: string): MerchantLib { - const newURL = new URL(`instance/${instanceId}/`, rootUrl); - const api = buildMerchantApiClient(newURL, evictors); + const api = buildMerchantApiClient( + instance.getSubInstanceAPI(instanceId) as URL, + evictors, + ); return api.lib; } async function getRemoteConfig(): Promise<TalerMerchantApi.VersionResponse> { const resp = await instance.getConfig(); if (resp.type === "fail") { - throw TalerError.fromUncheckedDetail(resp.detail) + throw TalerError.fromUncheckedDetail(resp.detail); } return resp.body; } |