diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/wxBackend.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/wxBackend.ts | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts b/packages/taler-wallet-webextension/src/wxBackend.ts index 0801d2ab0..2f48a6611 100644 --- a/packages/taler-wallet-webextension/src/wxBackend.ts +++ b/packages/taler-wallet-webextension/src/wxBackend.ts @@ -24,6 +24,7 @@ * Imports. */ import { + AbsoluteTime, LogLevel, Logger, OpenedPromise, @@ -33,7 +34,7 @@ import { makeErrorDetail, openPromise, setGlobalLogLevelFromString, - setLogLevelFromString, + setLogLevelFromString } from "@gnu-taler/taler-util"; import { HttpRequestLibrary } from "@gnu-taler/taler-util/http"; import { @@ -53,7 +54,7 @@ import { import { MessageFromFrontend, MessageResponse } from "./platform/api.js"; import { platform } from "./platform/background.js"; import { ExtensionOperations } from "./taler-wallet-interaction-loader.js"; -import { BackgroundOperations } from "./wxApi.js"; +import { BackgroundOperations, WalletEvent } from "./wxApi.js"; /** * Currently active wallet instance. Might be unloaded and @@ -91,6 +92,12 @@ async function resetDb(): Promise<void> { await reinitWallet(); } +//FIXME: maybe circular buffer +const notifications: WalletEvent[] = [] +async function getNotifications(): Promise<WalletEvent[]> { + return notifications +} + async function runGarbageCollector(): Promise<void> { const dbBeforeGc = currentDatabase; if (!dbBeforeGc) { @@ -129,6 +136,8 @@ async function isDomainTrusted(): Promise<boolean> { const backendHandlers: BackendHandlerType = { resetDb, runGarbageCollector, + getNotifications, + reinitWallet, setLoggingLevel, }; @@ -284,12 +293,14 @@ async function reinitWallet(): Promise<void> { ); try { await wallet.handleCoreApiRequest("initWallet", "native-init", { - testing: { - emitObservabilityEvents: true, - }, - features: { - allowHttp: settings.walletAllowHttp, - }, + config: { + testing: { + emitObservabilityEvents: settings.showWalletActivity, + }, + features: { + allowHttp: settings.walletAllowHttp, + }, + } }); } catch (e) { logger.error("could not initialize wallet", e); @@ -297,6 +308,13 @@ async function reinitWallet(): Promise<void> { return; } wallet.addNotificationListener((message) => { + if (settings.showWalletActivity) { + notifications.push({ + notification: message, + when: AbsoluteTime.now() + }) + } + platform.sendMessageToAllChannels({ type: "wallet", notification: message, |