From 2e344093305ddf72f97e099cba107356970bb1e4 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 6 Mar 2024 12:29:33 -0300 Subject: transition when withdrawal operation updated --- .../src/components/WalletActivity.tsx | 66 ++++++++++++++++------ 1 file changed, 50 insertions(+), 16 deletions(-) (limited to 'packages/taler-wallet-webextension/src/components/WalletActivity.tsx') 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; 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 {
{ - setNotifications([]) + api.background.call("clearNotifications", undefined).then(d => { + refresh(api, setNotifications) + }) }}> clear
-- cgit v1.2.3