diff --git a/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts b/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts index d7d9f2da7..b744b80e5 100644 --- a/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts +++ b/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts @@ -60,8 +60,8 @@ export function useComponentState({ parsed !== undefined ? parsed : currency !== undefined - ? Amounts.zeroOfCurrency(currency) - : undefined; + ? Amounts.zeroOfCurrency(currency) + : undefined; // const [accountIdx, setAccountIdx] = useState(0); const [selectedAccount, setSelectedAccount] = useState(); @@ -147,7 +147,7 @@ export function useComponentState({ initialValue ?? ({} as any), ); const amountStr = Amounts.stringify(amount); - const depositPaytoUri = `payto://${currentAccount.targetType}/${currentAccount.targetPath}`; + const depositPaytoUri = stringifyPaytoUri(currentAccount); // eslint-disable-next-line react-hooks/rules-of-hooks const hook = useAsyncAsHook(async () => { @@ -193,8 +193,8 @@ export function useComponentState({ const amountError = !isDirty ? undefined : Amounts.cmp(balance, amount) === -1 - ? `Too much, your current balance is ${Amounts.stringifyValue(balance)}` - : undefined; + ? `Too much, your current balance is ${Amounts.stringifyValue(balance)}` + : undefined; const unableToDeposit = Amounts.isZero(totalToDeposit) || //deposit may be zero because of fee diff --git a/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts b/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts index f7383d483..50e71c144 100644 --- a/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts +++ b/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts @@ -128,7 +128,7 @@ export function useComponentState({ }), }, accountByType, - deleteAccount, + deleteAccount: pushAlertOnError(deleteAccount), onAccountAdded: { onClick: unableToAdd ? undefined : pushAlertOnError(addAccount), }, diff --git a/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx b/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx index e5be8d17d..75e1feca4 100644 --- a/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx +++ b/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx @@ -15,10 +15,12 @@ */ import { + buildPayto, KnownBankAccountsInfo, PaytoUriBitcoin, PaytoUriIBAN, PaytoUriTalerBank, + stringifyPaytoUri, } from "@gnu-taler/taler-util"; import { styled } from "@linaria/react"; import { Fragment, h, VNode } from "preact"; @@ -411,7 +413,8 @@ function BitcoinAddressAccount({ field }: { field: TextFieldHandler }): VNode { onChange={(v) => { setValue(v); if (!errors && field.onInput) { - field.onInput(`payto://bitcoin/${v}`); + const p = buildPayto("bitcoin", v, undefined); + field.onInput(stringifyPaytoUri(p)); } }} /> @@ -448,8 +451,9 @@ function TalerBankAddressAccount({ disabled={!field.onInput} onChange={(v) => { setHost(v); - if (!errors && field.onInput) { - field.onInput(`payto://x-taler-bank/${v}/${account}`); + if (!errors && field.onInput && account) { + const p = buildPayto("x-taler-bank", v, account); + field.onInput(stringifyPaytoUri(p)); } }} /> @@ -462,8 +466,9 @@ function TalerBankAddressAccount({ error={account !== undefined ? errors?.account : undefined} onChange={(v) => { setAccount(v || ""); - if (!errors && field.onInput) { - field.onInput(`payto://x-taler-bank/${host}/${v}`); + if (!errors && field.onInput && host) { + const p = buildPayto("x-taler-bank", host, v); + field.onInput(stringifyPaytoUri(p)); } }} /> @@ -500,10 +505,9 @@ function IbanAddressAccount({ field }: { field: TextFieldHandler }): VNode { name: string, ): void { if (!errors && field.onInput) { - const path = bic === undefined ? iban : `${bic}/${iban}`; - field.onInput( - `payto://iban/${path}?receiver-name=${encodeURIComponent(name)}`, - ); + const p = buildPayto("iban", iban, bic); + p.params["receiver-name"] = name; + field.onInput(stringifyPaytoUri(p)); } } return ( diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx index 7c0682588..397972636 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx @@ -202,20 +202,24 @@ function TransactionTemplate({ const SHOWING_RETRY_THRESHOLD_SECS = 30; const showSend = false; - // (transaction.type === TransactionType.PeerPullCredit || - // transaction.type === TransactionType.PeerPushDebit) && - // !transaction.info.completed; - const showRetry = - transaction.error !== undefined || - transaction.timestamp.t_s === "never" || - (transaction.extendedStatus === ExtendedStatus.Pending && - differenceInSeconds(new Date(), transaction.timestamp.t_s * 1000) > - SHOWING_RETRY_THRESHOLD_SECS); + const hasCancelTransactionImplemented = + transaction.type === TransactionType.Payment; const transactionStillActive = transaction.extendedStatus !== ExtendedStatus.Aborted && transaction.extendedStatus !== ExtendedStatus.Done && transaction.extendedStatus !== ExtendedStatus.Failed; + + // show retry if there is an error in an active state, or after some time + // if it is not aborting + const showRetry = + transactionStillActive && + (transaction.error !== undefined || + (transaction.extendedStatus !== ExtendedStatus.Aborting && + (transaction.timestamp.t_s === "never" || + differenceInSeconds(new Date(), transaction.timestamp.t_s * 1000) > + SHOWING_RETRY_THRESHOLD_SECS))); + return (
@@ -353,13 +357,15 @@ function TransactionTemplate({ ) : null} {transactionStillActive ? ( - + hasCancelTransactionImplemented ? ( + + ) : undefined ) : (