diff options
author | Sebastian <sebasjm@gmail.com> | 2023-04-14 14:16:08 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-04-14 14:16:25 -0300 |
commit | 6e060da237af35796b1b34dce108f05eef44ceb3 (patch) | |
tree | 6e21db09f1dd75f02821811ae165f056d2087be8 /packages/taler-wallet-webextension/src/context/alert.ts | |
parent | 5ea22a325c069fe497b2dc8a73d4de69fd8cc27b (diff) | |
download | wallet-core-6e060da237af35796b1b34dce108f05eef44ceb3.tar.xz |
some changes
using transaction context from web utils
alertContext.safely api change (easier to integrate)
using lang and localstorage from web utils
removing auto permission, from UI
adding settings
Diffstat (limited to 'packages/taler-wallet-webextension/src/context/alert.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/context/alert.ts | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/packages/taler-wallet-webextension/src/context/alert.ts b/packages/taler-wallet-webextension/src/context/alert.ts index 2b088abd3..b8918dc58 100644 --- a/packages/taler-wallet-webextension/src/context/alert.ts +++ b/packages/taler-wallet-webextension/src/context/alert.ts @@ -25,6 +25,7 @@ import { useContext, useState } from "preact/hooks"; import { HookError } from "../hooks/useAsyncAsHook.js"; import { SafeHandler, withSafe } from "../mui/handlers.js"; import { BackgroundError } from "../wxApi.js"; +import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser"; export type AlertType = "info" | "warning" | "error" | "success"; @@ -55,10 +56,7 @@ type Type = { * @deprecated use safely */ pushAlertOnError: <T>(h: (p: T) => Promise<void>) => SafeHandler<T>; - safely: <T>( - h: (p: T) => Promise<void>, - error: TranslatedString, - ) => SafeHandler<T>; + safely: <T>(name: string, h: (p: T) => Promise<void>) => SafeHandler<T>; }; const initial: Type = { @@ -113,10 +111,13 @@ export const AlertProvider = ({ children }: Props): VNode => { }); } + const { i18n } = useTranslationContext(); + function safely<T>( + name: string, handler: (p: T) => Promise<void>, - message: TranslatedString, ): SafeHandler<T> { + const message = i18n.str`Error was thrown trying to: "${name}"`; return withSafe(handler, (e) => { const a = alertFromError(message, e); pushAlert(a); |