From 41ab855736815d33f5fdbebc896b167c71482eee Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 25 Apr 2022 23:07:31 -0300 Subject: remove old async hook --- .../src/hooks/useAsyncAsHook.ts | 44 ---------------------- 1 file changed, 44 deletions(-) (limited to 'packages/taler-wallet-webextension/src/hooks') diff --git a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts index d03455ff7..04a6dbb18 100644 --- a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts +++ b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts @@ -47,50 +47,6 @@ export type HookResponse = HookOk | HookError | undefined; export type HookResponseWithRetry = ((HookOk | HookError) & WithRetry) | undefined; export function useAsyncAsHook( - fn: () => Promise, - updateOnNotification?: Array, - deps?: any[], -): HookResponse { - - const args = useMemo(() => ({ - fn, updateOnNotification - // eslint-disable-next-line react-hooks/exhaustive-deps - }), deps || []) - const [result, setHookResponse] = useState>(undefined); - - useEffect(() => { - async function doAsync(): Promise { - try { - const response = await args.fn(); - if (response === false) return; - setHookResponse({ hasError: false, response }); - } catch (e) { - if (e instanceof TalerError) { - setHookResponse({ - hasError: true, - operational: true, - details: e.errorDetail, - }); - } else if (e instanceof Error) { - setHookResponse({ - hasError: true, - operational: false, - message: e.message, - }); - } - } - } - doAsync(); - if (args.updateOnNotification && args.updateOnNotification.length > 0) { - return wxApi.onUpdateNotification(args.updateOnNotification, () => { - doAsync(); - }); - } - }, [args]); - return result; -} - -export function useAsyncAsHook2( fn: () => Promise, deps?: any[], ): HookResponseWithRetry { -- cgit v1.2.3