From 4a781bd0dd8828ce152f6ab2c3f1bbd6b5e826f7 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 9 Jan 2023 20:20:09 -0300 Subject: fix #7153: more error handling if handler do not trap error then fail at compile time, all safe handlers push alert on error errors are typed so they render good information --- .../src/wallet/ManageAccount/state.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts') diff --git a/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts b/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts index 176a8d100..f7383d483 100644 --- a/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts +++ b/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts @@ -21,7 +21,7 @@ import { } from "@gnu-taler/taler-util"; 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({ onCancel, }: Props): State { const api = useBackendContext(); + const { pushAlertOnError } = useAlertContext(); const { i18n } = useTranslationContext(); const hook = useAsyncAsHook(() => api.wallet.call(WalletApiOperation.ListKnownBankAccounts, { currency }), @@ -109,30 +110,30 @@ export function useComponentState({ accountType: { list: accountType, value: type, - onChange: async (v) => { + onChange: pushAlertOnError(async (v) => { setType(v); - }, + }), }, alias: { value: alias, - onInput: async (v) => { + onInput: pushAlertOnError(async (v) => { setAlias(v); - }, + }), }, uri: { value: payto, error: paytoUriError, - onInput: async (v) => { + onInput: pushAlertOnError(async (v) => { setPayto(v); - }, + }), }, accountByType, deleteAccount, onAccountAdded: { - onClick: unableToAdd ? undefined : addAccount, + onClick: unableToAdd ? undefined : pushAlertOnError(addAccount), }, onCancel: { - onClick: async () => onCancel(), + onClick: pushAlertOnError(async () => onCancel()), }, }; } -- cgit v1.2.3