diff options
author | Sebastian <sebasjm@gmail.com> | 2022-12-21 16:36:24 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-12-21 16:36:24 -0300 |
commit | a73d24759c4de897af111daaf3022cac6f5c30da (patch) | |
tree | 7002c2b354df31d007db42195c970f5ef764432f | |
parent | 7873571d225347aa2174b6d8943d9df820f8817c (diff) |
testing function sum and freeze
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx | 24 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/wxApi.ts | 8 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/wxBackend.ts | 12 |
3 files changed, 44 insertions, 0 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx index cbf6b1c0a..0916f4f43 100644 --- a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx +++ b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx @@ -200,6 +200,30 @@ export function View({ <Grid item> <Button variant="contained" + onClick={() => { + return api.background.call("sum", [1, 2, 3]).then((r) => { + console.log("SUM", r); + }); + }} + > + <i18n.Translate>sum 123</i18n.Translate> + </Button> + </Grid> + <Grid item> + <Button + variant="contained" + onClick={() => { + return api.background.call("freeze", 5000).then(() => { + console.log("WAIT"); + }); + }} + > + <i18n.Translate>freeze 5000</i18n.Translate> + </Button> + </Grid> + <Grid item> + <Button + variant="contained" onClick={async () => fileRef?.current?.click()} > <i18n.Translate>import database</i18n.Translate> diff --git a/packages/taler-wallet-webextension/src/wxApi.ts b/packages/taler-wallet-webextension/src/wxApi.ts index ea087fc5d..4ec51fc78 100644 --- a/packages/taler-wallet-webextension/src/wxApi.ts +++ b/packages/taler-wallet-webextension/src/wxApi.ts @@ -53,6 +53,14 @@ export interface ExtendedPermissionsResponse { } export interface BackgroundOperations { + freeze: { + request: number; + response: void; + }; + sum: { + request: number[], + response: number, + } resetDb: { request: void; response: void; diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts b/packages/taler-wallet-webextension/src/wxBackend.ts index c94b390ff..d54dc818f 100644 --- a/packages/taler-wallet-webextension/src/wxBackend.ts +++ b/packages/taler-wallet-webextension/src/wxBackend.ts @@ -162,7 +162,19 @@ async function toggleHeaderListener( return { newValue: false }; } +function freeze(time: number): Promise<void> { + return new Promise((res, rej) => { + setTimeout(res, time) + }) +} + +async function sum(ns: Array<number>): Promise<number> { + return ns.reduce((prev, cur) => prev + cur, 0) +} + const backendHandlers: BackendHandlerType = { + freeze, + sum, containsHeaderListener, getDiagnostics, resetDb, |