diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src')
6 files changed, 64 insertions, 19 deletions
diff --git a/packages/taler-wallet-webextension/src/components/WalletActivity.tsx b/packages/taler-wallet-webextension/src/components/WalletActivity.tsx index 48a562098..316596fb4 100644 --- a/packages/taler-wallet-webextension/src/components/WalletActivity.tsx +++ b/packages/taler-wallet-webextension/src/components/WalletActivity.tsx @@ -35,7 +35,7 @@ import { useSettings } from "../hooks/useSettings.js"; import { Button } from "../mui/Button.js"; import { Modal } from "./Modal.js"; import { Time } from "./Time.js"; -import { WalletEvent } from "../wxApi.js"; +import { WalletEvent, WxApiType } from "../wxApi.js"; interface Props extends JSX.HTMLAttributes { } @@ -587,6 +587,27 @@ function getNotificationFor(id: string, event: WalletNotification, start: Absolu MoreInfo: ShowObservabilityEvent }) } + case NotificationType.WithdrawalOperationTransition: { + const found = list.find(a => a.reference?.eventType === event.type && a.reference.id === event.uri) + if (found) { + found.end = start; + found.events.unshift(eventWithTime) + return undefined + } + return ({ + id, + events: [eventWithTime], + reference: { + eventType: event.type, + referenceType: "task", + id: event.uri, + }, + description: `Withdrawal operation updated`, + start, + end: AbsoluteTime.never(), + MoreInfo: ShowObservabilityEvent + }) + } case NotificationType.RequestObservabilityEvent: { const found = list.find(a => a.reference?.eventType === event.type && a.reference.id === event.requestId) if (found) { @@ -614,6 +635,29 @@ function getNotificationFor(id: string, event: WalletNotification, start: Absolu } } + +function refresh(api: WxApiType, onUpdate: (list: Notif[]) => void) { + api.background.call("getNotifications", undefined).then(notif => { + + const list: Notif[] = [] + for (const n of notif) { + if (n.notification.type === NotificationType.RequestObservabilityEvent && + n.notification.operation === "getActiveTasks") { + //ignore monitor request + continue; + } + const event = getNotificationFor(String(list.length), n.notification, n.when, list) + // pepe. + if (event) { + list.unshift(event) + } + } + onUpdate(list); + }).catch(error => { + console.log(error) + }) +} + export function ObservabilityEventsTable({ }: {}): VNode { const { i18n } = useTranslationContext() const api = useBackendContext(); @@ -624,20 +668,8 @@ export function ObservabilityEventsTable({ }: {}): VNode { useEffect(() => { let lastTimeout: ReturnType<typeof setTimeout>; function periodicRefresh() { - api.background.call("getNotifications", undefined).then(notif => { - - const list: Notif[] = [] - for (const pepe of notif) { - const event = getNotificationFor(String(list.length), pepe.notification, pepe.when, list) - // pepe. - if (event) { - list.unshift(event) - } - } - setNotifications(list); - }).catch(error => { - console.log(error) - }) + + refresh(api, setNotifications) lastTimeout = setTimeout(() => { periodicRefresh(); @@ -653,7 +685,9 @@ export function ObservabilityEventsTable({ }: {}): VNode { <div style={{ display: "flex", justifyContent: "space-between" }}> <div style={{ padding: 4, margin: 2, border: "solid 1px black" }} onClick={() => { - setNotifications([]) + api.background.call("clearNotifications", undefined).then(d => { + refresh(api, setNotifications) + }) }}> clear </div> diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts index e52b9faec..05aef690e 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts @@ -243,8 +243,8 @@ export function useComponentStateFromURI({ return; } return api.listener.onUpdateNotification( - [NotificationType.TransactionStateTransition], - () => { + [NotificationType.WithdrawalOperationTransition], + (asd) => { uriInfoHook.retry(); }, ); diff --git a/packages/taler-wallet-webextension/src/hooks/useSettings.ts b/packages/taler-wallet-webextension/src/hooks/useSettings.ts index 37d2f13d7..a79a71087 100644 --- a/packages/taler-wallet-webextension/src/hooks/useSettings.ts +++ b/packages/taler-wallet-webextension/src/hooks/useSettings.ts @@ -59,6 +59,6 @@ export function useSettings(): [ function updateField<T extends keyof Settings>(k: T, v: Settings[T]) { update({ ...value, [k]: v }); } - console.log("ASDeeeeASD") + return [value, updateField]; } diff --git a/packages/taler-wallet-webextension/src/wallet/AddBackupProvider/test.ts b/packages/taler-wallet-webextension/src/wallet/AddBackupProvider/test.ts index 66f64d82e..9c68b28cf 100644 --- a/packages/taler-wallet-webextension/src/wallet/AddBackupProvider/test.ts +++ b/packages/taler-wallet-webextension/src/wallet/AddBackupProvider/test.ts @@ -45,6 +45,7 @@ describe("AddBackupProvider states", () => { expect(state.name.value).eq(""); expect(state.url.value).eq(""); }, + //FIXME: this shouldn't take 2 updates, just (state) => { expect(state.status).equal("select-provider"); if (state.status !== "select-provider") return; diff --git a/packages/taler-wallet-webextension/src/wxApi.ts b/packages/taler-wallet-webextension/src/wxApi.ts index 90522f662..495f015ff 100644 --- a/packages/taler-wallet-webextension/src/wxApi.ts +++ b/packages/taler-wallet-webextension/src/wxApi.ts @@ -78,6 +78,10 @@ export interface BackgroundOperations { request: void; response: WalletEvent[]; }; + clearNotifications: { + request: void; + response: void; + }; setLoggingLevel: { request: { tag?: string; diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts b/packages/taler-wallet-webextension/src/wxBackend.ts index c7408ed87..195e05687 100644 --- a/packages/taler-wallet-webextension/src/wxBackend.ts +++ b/packages/taler-wallet-webextension/src/wxBackend.ts @@ -100,6 +100,11 @@ async function getNotifications(): Promise<WalletEvent[]> { return notifications } +async function clearNotifications(): Promise<void> { + notifications.splice(0,notifications.length) +} + + async function runGarbageCollector(): Promise<void> { const dbBeforeGc = currentDatabase; if (!dbBeforeGc) { @@ -139,6 +144,7 @@ const backendHandlers: BackendHandlerType = { resetDb, runGarbageCollector, getNotifications, + clearNotifications, reinitWallet, setLoggingLevel, }; |