aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts')
-rw-r--r--packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts41
1 files changed, 21 insertions, 20 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts
index cfb32cbbb..7ad11e67c 100644
--- a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts
+++ b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts
@@ -20,7 +20,7 @@ import {
WalletApiOperation,
} from "@gnu-taler/taler-wallet-core";
import { useState } from "preact/hooks";
-import { alertFromError } from "../../context/alert.js";
+import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
@@ -33,6 +33,7 @@ export function useComponentState({
currentExchange,
}: Props): State {
const api = useBackendContext();
+ const { pushAlertOnError } = useAlertContext();
const { i18n } = useTranslationContext();
const initialValue = exchanges.findIndex(
(e) => e.exchangeBaseUrl === currentExchange,
@@ -115,7 +116,7 @@ export function useComponentState({
status: "showing-privacy",
error: undefined,
onClose: {
- onClick: async () => setShowingPrivacy(undefined),
+ onClick: pushAlertOnError(async () => setShowingPrivacy(undefined)),
},
exchangeUrl: showingPrivacy,
};
@@ -125,7 +126,7 @@ export function useComponentState({
status: "showing-tos",
error: undefined,
onClose: {
- onClick: async () => setShowingTos(undefined),
+ onClick: pushAlertOnError(async () => setShowingTos(undefined)),
},
exchangeUrl: showingTos,
};
@@ -138,24 +139,24 @@ export function useComponentState({
exchanges: {
list: exchangeMap,
value: value,
- onChange: async (v) => {
+ onChange: pushAlertOnError(async (v) => {
setValue(v);
- },
+ }),
},
error: undefined,
onClose: {
- onClick: onCancel,
+ onClick: pushAlertOnError(onCancel),
},
selected,
onShowPrivacy: {
- onClick: async () => {
+ onClick: pushAlertOnError(async () => {
setShowingPrivacy(selected.exchangeBaseUrl);
- },
+ }),
},
onShowTerms: {
- onClick: async () => {
+ onClick: pushAlertOnError(async () => {
setShowingTos(selected.exchangeBaseUrl);
- },
+ }),
},
};
}
@@ -215,30 +216,30 @@ export function useComponentState({
exchanges: {
list: exchangeMap,
value: value,
- onChange: async (v) => {
+ onChange: pushAlertOnError(async (v) => {
setValue(v);
- },
+ }),
},
error: undefined,
onReset: {
- onClick: async () => {
+ onClick: pushAlertOnError(async () => {
setValue(String(initialValue));
- },
+ }),
},
onSelect: {
- onClick: async () => {
+ onClick: pushAlertOnError(async () => {
onSelection(selected.exchangeBaseUrl);
- },
+ }),
},
onShowPrivacy: {
- onClick: async () => {
+ onClick: pushAlertOnError(async () => {
setShowingPrivacy(selected.exchangeBaseUrl);
- },
+ }),
},
onShowTerms: {
- onClick: async () => {
+ onClick: pushAlertOnError(async () => {
setShowingTos(selected.exchangeBaseUrl);
- },
+ }),
},
selected,
coinOperationTimeline,