diff options
author | Sebastian <sebasjm@gmail.com> | 2024-03-06 12:29:33 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-03-06 12:29:33 -0300 |
commit | 2e344093305ddf72f97e099cba107356970bb1e4 (patch) | |
tree | 3051279ae2bc54b62597d045b37f7ee76370bf03 /packages/taler-wallet-webextension/src/components | |
parent | e89d2098041d265131915c4e006a51478ff664bb (diff) | |
download | wallet-core-2e344093305ddf72f97e099cba107356970bb1e4.tar.xz |
transition when withdrawal operation updated
Diffstat (limited to 'packages/taler-wallet-webextension/src/components')
-rw-r--r-- | packages/taler-wallet-webextension/src/components/WalletActivity.tsx | 66 |
1 files changed, 50 insertions, 16 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> |