summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-util/src/notifications.ts12
-rw-r--r--packages/taler-wallet-core/src/pay-merchant.ts6
-rw-r--r--packages/taler-wallet-core/src/withdraw.ts18
-rw-r--r--packages/taler-wallet-webextension/src/components/WalletActivity.tsx66
-rw-r--r--packages/taler-wallet-webextension/src/cta/Withdraw/state.ts4
-rw-r--r--packages/taler-wallet-webextension/src/hooks/useSettings.ts2
-rw-r--r--packages/taler-wallet-webextension/src/wallet/AddBackupProvider/test.ts1
-rw-r--r--packages/taler-wallet-webextension/src/wxApi.ts4
-rw-r--r--packages/taler-wallet-webextension/src/wxBackend.ts6
9 files changed, 86 insertions, 33 deletions
diff --git a/packages/taler-util/src/notifications.ts b/packages/taler-util/src/notifications.ts
index 023eb8ef4..ab28cc2ee 100644
--- a/packages/taler-util/src/notifications.ts
+++ b/packages/taler-util/src/notifications.ts
@@ -29,6 +29,7 @@ export enum NotificationType {
BalanceChange = "balance-change",
BackupOperationError = "backup-error",
TransactionStateTransition = "transaction-state-transition",
+ WithdrawalOperationTransition = "withdrawal-operation-transition",
ExchangeStateTransition = "exchange-state-transition",
TaskObservabilityEvent = "task-observability-event",
RequestObservabilityEvent = "request-observability-event",
@@ -205,9 +206,20 @@ export interface BackupOperationErrorNotification {
type: NotificationType.BackupOperationError;
error: TalerErrorDetail;
}
+/**
+ * This notification is required to signal UI that
+ * the withdrawal operation changed the state.
+ *
+ * https://bugs.gnunet.org/view.php?id=8099
+ */
+export interface WithdrawalOperationTransitionNotification {
+ type: NotificationType.WithdrawalOperationTransition;
+ uri: string;
+}
export type WalletNotification =
| BalanceChangeNotification
+ | WithdrawalOperationTransitionNotification
| BackupOperationErrorNotification
| ExchangeStateTransitionNotification
| TransactionStateTransitionNotification
diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts
index c5af25307..a3623e6d2 100644
--- a/packages/taler-wallet-core/src/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/pay-merchant.ts
@@ -617,8 +617,7 @@ async function processDownloadProposal(
if (proposal.purchaseStatus != PurchaseStatus.PendingDownloadingProposal) {
logger.error(
- `unexpected state ${proposal.purchaseStatus}/${
- PurchaseStatus[proposal.purchaseStatus]
+ `unexpected state ${proposal.purchaseStatus}/${PurchaseStatus[proposal.purchaseStatus]
} for ${ctx.transactionId} in processDownloadProposal`,
);
return TaskRunResult.finished();
@@ -874,8 +873,7 @@ async function createOrReusePurchase(
oldProposal.claimToken === claimToken
) {
logger.info(
- `Found old proposal (status=${
- PurchaseStatus[oldProposal.purchaseStatus]
+ `Found old proposal (status=${PurchaseStatus[oldProposal.purchaseStatus]
}) for order ${orderId} at ${merchantBaseUrl}`,
);
if (oldProposal.purchaseStatus === PurchaseStatus.DialogShared) {
diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts
index e3c4e66a2..853a5e0df 100644
--- a/packages/taler-wallet-core/src/withdraw.ts
+++ b/packages/taler-wallet-core/src/withdraw.ts
@@ -1922,22 +1922,20 @@ export async function getWithdrawalDetailsForUri(
info.apiBaseUrl,
wex.http,
);
- console.log(
- `waiting operation (${info.operationId}) to change from pending`,
- );
+
bankApi
.getWithdrawalOperationById(info.operationId, {
old_state: "pending",
timeoutMs: opts.notifyChangeFromPendingTimeoutMs,
})
.then((resp) => {
- console.log(
- `operation (${info.operationId}) to change to ${JSON.stringify(
- resp,
- undefined,
- 2,
- )}`,
- );
+ if (resp.type === "ok" && resp.body.status !== "pending") {
+ wex.ws.notify({
+ type: NotificationType.WithdrawalOperationTransition,
+ uri: talerWithdrawUri,
+ });
+ }
+ }).finally(() => {
ongoingChecks[talerWithdrawUri] = false;
});
}
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,
};