diff options
author | Sebastian <sebasjm@gmail.com> | 2022-04-29 13:16:29 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-04-29 15:49:16 -0300 |
commit | 038dcbc9b7378552bd5b0548fe373dbd2867c971 (patch) | |
tree | 2bef67bf7dd4f8ae9e6981809b3198bb1f56f38e /packages/taler-wallet-webextension | |
parent | a1ad9727eec21a231d83fc08d14547454769374c (diff) |
fix #5845 added run-gc on webex
Diffstat (limited to 'packages/taler-wallet-webextension')
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx | 17 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/wxApi.ts | 8 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/wxBackend.ts | 14 |
3 files changed, 37 insertions, 2 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx index e371775f4..829e60b44 100644 --- a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx +++ b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx @@ -36,7 +36,8 @@ export function DeveloperPage(): VNode { const [status, timedOut] = useDiagnostics(); const listenAllEvents = Array.from<NotificationType>({ length: 1 }); - listenAllEvents.includes = () => true; // includes every event + //FIXME: waiting for retry notification make a always increasing loop of notifications + listenAllEvents.includes = (e) => e !== "waiting-for-retry"; // includes every event const response = useAsyncAsHook(async () => { const op = await wxApi.getPendingOperations(); @@ -160,11 +161,22 @@ export function View({ onClick={() => confirmReset( i18n.str`Do you want to IRREVOCABLY DESTROY everything inside your wallet and LOSE ALL YOUR COINS?`, + wxApi.resetDb, ) } > <i18n.Translate>reset</i18n.Translate> </button> + <button + onClick={() => + confirmReset( + i18n.str`TESTING: This may delete all your coin, proceed with caution`, + wxApi.runGarbageCollector, + ) + } + > + <i18n.Translate>run gc</i18n.Translate> + </button> <br /> <button onClick={() => fileRef?.current?.click()}> <i18n.Translate>import database</i18n.Translate> @@ -385,9 +397,10 @@ function toBase64(str: string): string { export async function confirmReset( confirmTheResetMessage: string, + cb: () => Promise<void>, ): Promise<void> { if (confirm(confirmTheResetMessage)) { - await wxApi.resetDb(); + await cb(); window.close(); } } diff --git a/packages/taler-wallet-webextension/src/wxApi.ts b/packages/taler-wallet-webextension/src/wxApi.ts index da80e9bde..3079392b6 100644 --- a/packages/taler-wallet-webextension/src/wxApi.ts +++ b/packages/taler-wallet-webextension/src/wxApi.ts @@ -140,6 +140,14 @@ export function resetDb(): Promise<void> { return callBackend("reset-db", {}); } +/** + * Reset database + */ +export function runGarbageCollector(): Promise<void> { + return callBackend("run-gc", {}); +} + + export function getFeeForDeposit( depositPaytoUri: string, amount: AmountString, diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts b/packages/taler-wallet-webextension/src/wxBackend.ts index 2ac8f6343..f5483e807 100644 --- a/packages/taler-wallet-webextension/src/wxBackend.ts +++ b/packages/taler-wallet-webextension/src/wxBackend.ts @@ -33,6 +33,8 @@ import { import { DbAccess, deleteTalerDatabase, + exportDb, + importDb, makeErrorDetail, OpenedPromise, openPromise, @@ -129,6 +131,18 @@ async function dispatch( r = wrapResponse(await reinitWallet()); break; } + case "run-gc": { + logger.info("gc") + const dump = await exportDb(currentDatabase!.idbHandle()); + await deleteTalerDatabase(indexedDB as any); + logger.info("cleaned") + await reinitWallet(); + logger.info("init") + await importDb(currentDatabase!.idbHandle(), dump) + logger.info("imported") + r = wrapResponse({ result: true }); + break; + } case "containsHeaderListener": { const res = await platform.containsTalerHeaderListener(); r = wrapResponse({ newValue: res }); |