gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated (bbd6ccf1 -> 89435696)


From: gnunet
Subject: [taler-wallet-core] branch master updated (bbd6ccf1 -> 89435696)
Date: Wed, 30 Mar 2022 19:36:33 +0200

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a change to branch master
in repository wallet-core.

    from bbd6ccf1 wallet: allow forced denom selection for tests
     new 8642f8ed fix loop rendering
     new 89435696 useAsync use an optional deps for callback, most of the time 
it just need to be rendered once

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../taler-wallet-webextension/src/cta/Deposit.tsx  |  3 +-
 packages/taler-wallet-webextension/src/cta/Pay.tsx |  2 ++
 .../taler-wallet-webextension/src/cta/Withdraw.tsx | 41 ++++++++++++++--------
 .../src/hooks/useAsyncAsHook.ts                    | 18 ++++++----
 .../src/hooks/useTalerActionURL.test.ts            |  1 +
 .../src/mui/input/FormControl.tsx                  | 10 ++++--
 .../src/mui/input/InputBase.tsx                    |  2 +-
 .../src/platform/chrome.ts                         |  1 +
 .../src/wallet/CreateManualWithdraw.test.ts        |  1 +
 .../src/wallet/CreateManualWithdraw.tsx            |  1 +
 .../src/wallet/DepositPage.stories.tsx             |  1 +
 .../src/wallet/DepositPage.tsx                     |  3 +-
 .../src/wallet/ExchangeSetUrl.tsx                  |  2 +-
 .../src/wallet/ProviderAddPage.tsx                 |  3 +-
 .../taler-wallet-webextension/src/wxBackend.ts     |  1 -
 15 files changed, 60 insertions(+), 30 deletions(-)

diff --git a/packages/taler-wallet-webextension/src/cta/Deposit.tsx 
b/packages/taler-wallet-webextension/src/cta/Deposit.tsx
index 7ade50e2..541bc733 100644
--- a/packages/taler-wallet-webextension/src/cta/Deposit.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Deposit.tsx
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-unused-vars */
 /*
  This file is part of TALER
  (C) 2015 GNUnet e.V.
@@ -197,7 +198,7 @@ export function PaymentRequestView({
   payStatus,
   payResult,
 }: PaymentRequestViewProps): VNode {
-  let totalFees: AmountJson = Amounts.getZero(payStatus.amountRaw);
+  const totalFees: AmountJson = Amounts.getZero(payStatus.amountRaw);
   const contractTerms: ContractTerms = payStatus.contractTerms;
   const { i18n } = useTranslationContext();
 
diff --git a/packages/taler-wallet-webextension/src/cta/Pay.tsx 
b/packages/taler-wallet-webextension/src/cta/Pay.tsx
index c2f35266..13fb6985 100644
--- a/packages/taler-wallet-webextension/src/cta/Pay.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Pay.tsx
@@ -1,3 +1,5 @@
+/* eslint-disable @typescript-eslint/no-unused-vars */
+/* eslint-disable @typescript-eslint/no-non-null-assertion */
 /*
  This file is part of TALER
  (C) 2015 GNUnet e.V.
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx 
b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx
index 67a91039..676c65d2 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx
@@ -28,7 +28,7 @@ import {
   WithdrawUriInfoResponse,
 } from "@gnu-taler/taler-util";
 import { Fragment, h, VNode } from "preact";
-import { useState } from "preact/hooks";
+import { useCallback, useMemo, useState } from "preact/hooks";
 import { Loading } from "../components/Loading.js";
 import { LoadingError } from "../components/LoadingError.js";
 import { ErrorTalerOperation } from "../components/ErrorTalerOperation.js";
@@ -247,23 +247,34 @@ export function WithdrawPageWithParsedURI({
   const [reviewing, setReviewing] = useState<boolean>(false);
   const [reviewed, setReviewed] = useState<boolean>(false);
 
-  const knownExchangesHook = useAsyncAsHook(() => wxApi.listExchanges());
+  const knownExchangesHook = useAsyncAsHook(wxApi.listExchanges);
 
-  const knownExchanges =
-    !knownExchangesHook || knownExchangesHook.hasError
-      ? []
-      : knownExchangesHook.response.exchanges;
-  const withdrawAmount = Amounts.parseOrThrow(uriInfo.amount);
-  const thisCurrencyExchanges = knownExchanges.filter(
-    (ex) => ex.currency === withdrawAmount.currency,
+  const knownExchanges = useMemo(
+    () =>
+      !knownExchangesHook || knownExchangesHook.hasError
+        ? []
+        : knownExchangesHook.response.exchanges,
+    [knownExchangesHook],
+  );
+  const withdrawAmount = useMemo(
+    () => Amounts.parseOrThrow(uriInfo.amount),
+    [uriInfo.amount],
+  );
+  const thisCurrencyExchanges = useMemo(
+    () =>
+      knownExchanges.filter((ex) => ex.currency === withdrawAmount.currency),
+    [knownExchanges, withdrawAmount.currency],
   );
 
-  const exchange: string | undefined =
-    customExchange ??
-    uriInfo.defaultExchangeBaseUrl ??
-    (thisCurrencyExchanges[0]
-      ? thisCurrencyExchanges[0].exchangeBaseUrl
-      : undefined);
+  const exchange: string | undefined = useMemo(
+    () =>
+      customExchange ??
+      uriInfo.defaultExchangeBaseUrl ??
+      (thisCurrencyExchanges[0]
+        ? thisCurrencyExchanges[0].exchangeBaseUrl
+        : undefined),
+    [customExchange, thisCurrencyExchanges, uriInfo.defaultExchangeBaseUrl],
+  );
 
   const detailsHook = useAsyncAsHook(async () => {
     if (!exchange) throw Error("no default exchange");
diff --git a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts 
b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts
index 68bc9aed..b2d71874 100644
--- a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts
+++ b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts
@@ -17,7 +17,7 @@ import {
   NotificationType, TalerErrorDetail
 } from "@gnu-taler/taler-util";
 import { TalerError } from "@gnu-taler/taler-wallet-core";
-import { useEffect, useState } from "preact/hooks";
+import { useCallback, useEffect, useMemo, useState } from "preact/hooks";
 import * as wxApi from "../wxApi.js";
 
 interface HookOk<T> {
@@ -41,16 +41,22 @@ export interface HookOperationalError {
 
 export type HookResponse<T> = HookOk<T> | HookError | undefined;
 
-//"withdraw-group-finished"
 export function useAsyncAsHook<T>(
   fn: () => Promise<T>,
   updateOnNotification?: Array<NotificationType>,
+  deps?: any[],
 ): HookResponse<T> {
+
+  const args = useMemo(() => ({
+    fn, updateOnNotification
+    // eslint-disable-next-line react-hooks/exhaustive-deps
+  }), deps || [])
   const [result, setHookResponse] = useState<HookResponse<T>>(undefined);
+
   useEffect(() => {
     async function doAsync(): Promise<void> {
       try {
-        const response = await fn();
+        const response = await args.fn();
         setHookResponse({ hasError: false, response });
       } catch (e) {
         if (e instanceof TalerError) {
@@ -69,11 +75,11 @@ export function useAsyncAsHook<T>(
       }
     }
     doAsync();
-    if (updateOnNotification && updateOnNotification.length > 0) {
-      return wxApi.onUpdateNotification(updateOnNotification, () => {
+    if (args.updateOnNotification && args.updateOnNotification.length > 0) {
+      return wxApi.onUpdateNotification(args.updateOnNotification, () => {
         doAsync();
       });
     }
-  });
+  }, [args]);
   return result;
 }
diff --git 
a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts 
b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts
index ed51d00e..25513f57 100644
--- a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts
+++ b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-non-null-assertion */
 /*
  This file is part of GNU Taler
  (C) 2021 Taler Systems S.A.
diff --git a/packages/taler-wallet-webextension/src/mui/input/FormControl.tsx 
b/packages/taler-wallet-webextension/src/mui/input/FormControl.tsx
index 8860ce20..0f73f8c0 100644
--- a/packages/taler-wallet-webextension/src/mui/input/FormControl.tsx
+++ b/packages/taler-wallet-webextension/src/mui/input/FormControl.tsx
@@ -1,6 +1,6 @@
 import { css } from "@linaria/core";
 import { ComponentChildren, createContext, h, VNode } from "preact";
-import { useContext, useState } from "preact/hooks";
+import { useContext, useMemo, useState } from "preact/hooks";
 // eslint-disable-next-line import/extensions
 import { Colors } from "../style";
 
@@ -152,6 +152,10 @@ function withoutUndefinedProperties(obj: any): any {
 export function useFormControl(props: Partial<FCCProps> = {}): FCCProps {
   const ctx = useContext(FormControlContext);
   const cleanedProps = withoutUndefinedProperties(props);
-  if (!ctx) return { ...defaultContextValue, ...cleanedProps };
-  return { ...ctx, ...cleanedProps };
+
+  return useMemo(() => {
+    return !ctx
+      ? { ...defaultContextValue, ...cleanedProps }
+      : { ...ctx, ...cleanedProps };
+  }, [cleanedProps, ctx]);
 }
diff --git a/packages/taler-wallet-webextension/src/mui/input/InputBase.tsx 
b/packages/taler-wallet-webextension/src/mui/input/InputBase.tsx
index a25366bd..a71f11c5 100644
--- a/packages/taler-wallet-webextension/src/mui/input/InputBase.tsx
+++ b/packages/taler-wallet-webextension/src/mui/input/InputBase.tsx
@@ -169,7 +169,7 @@ export function InputBase({
     } else {
       fcs.onEmpty();
     }
-  }, [value]);
+  }, [value, fcs]);
 
   const handleFocus = (event: JSX.TargetedFocusEvent<EventTarget>): void => {
     // Fix a bug with IE11 where the focus/blur events are triggered
diff --git a/packages/taler-wallet-webextension/src/platform/chrome.ts 
b/packages/taler-wallet-webextension/src/platform/chrome.ts
index 67b293ec..67779f08 100644
--- a/packages/taler-wallet-webextension/src/platform/chrome.ts
+++ b/packages/taler-wallet-webextension/src/platform/chrome.ts
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-non-null-assertion */
 /*
  This file is part of TALER
  (C) 2017 INRIA
diff --git 
a/packages/taler-wallet-webextension/src/wallet/CreateManualWithdraw.test.ts 
b/packages/taler-wallet-webextension/src/wallet/CreateManualWithdraw.test.ts
index 13ce322e..e6e699ce 100644
--- a/packages/taler-wallet-webextension/src/wallet/CreateManualWithdraw.test.ts
+++ b/packages/taler-wallet-webextension/src/wallet/CreateManualWithdraw.test.ts
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-non-null-assertion */
 /*
  This file is part of GNU Taler
  (C) 2021 Taler Systems S.A.
diff --git 
a/packages/taler-wallet-webextension/src/wallet/CreateManualWithdraw.tsx 
b/packages/taler-wallet-webextension/src/wallet/CreateManualWithdraw.tsx
index a549bf59..9d7a692a 100644
--- a/packages/taler-wallet-webextension/src/wallet/CreateManualWithdraw.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/CreateManualWithdraw.tsx
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-non-null-assertion */
 /*
  This file is part of GNU Taler
  (C) 2021 Taler Systems S.A.
diff --git 
a/packages/taler-wallet-webextension/src/wallet/DepositPage.stories.tsx 
b/packages/taler-wallet-webextension/src/wallet/DepositPage.stories.tsx
index cadd0c86..edc2f971 100644
--- a/packages/taler-wallet-webextension/src/wallet/DepositPage.stories.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/DepositPage.stories.tsx
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-non-null-assertion */
 /*
  This file is part of GNU Taler
  (C) 2021 Taler Systems S.A.
diff --git a/packages/taler-wallet-webextension/src/wallet/DepositPage.tsx 
b/packages/taler-wallet-webextension/src/wallet/DepositPage.tsx
index 375a03f8..335dfd3c 100644
--- a/packages/taler-wallet-webextension/src/wallet/DepositPage.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/DepositPage.tsx
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-non-null-assertion */
 /*
  This file is part of TALER
  (C) 2016 GNUnet e.V.
@@ -162,7 +163,7 @@ export function useComponentState(
     onCalculateFee(selectedAccount, parsedAmount).then((result) => {
       setFee(result);
     });
-  }, [amount]);
+  }, [amount, selectedAccount, parsedAmount, onCalculateFee]);
 
   const bs = balances.filter((b) => b.available.startsWith(currency));
   const balance =
diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeSetUrl.tsx 
b/packages/taler-wallet-webextension/src/wallet/ExchangeSetUrl.tsx
index ce1bcbeb..ad8cb7db 100644
--- a/packages/taler-wallet-webextension/src/wallet/ExchangeSetUrl.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ExchangeSetUrl.tsx
@@ -64,7 +64,7 @@ function useEndpointStatus<T>(
       }
     }, 500);
     setHandler(h);
-  }, [value]);
+  }, [value, setHandler, handler, onVerify]);
 
   return {
     error: dirty ? error : undefined,
diff --git a/packages/taler-wallet-webextension/src/wallet/ProviderAddPage.tsx 
b/packages/taler-wallet-webextension/src/wallet/ProviderAddPage.tsx
index e3a5b9cb..ed4a91f1 100644
--- a/packages/taler-wallet-webextension/src/wallet/ProviderAddPage.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ProviderAddPage.tsx
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-non-null-assertion */
 /*
  This file is part of GNU Taler
  (C) 2021 Taler Systems S.A.
@@ -112,7 +113,7 @@ export function SetUrlView({
       setUrlError(true);
       setName(undefined);
     }
-  }, [value]);
+  }, [onVerify, value]);
   return (
     <Fragment>
       <section>
diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts 
b/packages/taler-wallet-webextension/src/wxBackend.ts
index 02342063..7401fd4f 100644
--- a/packages/taler-wallet-webextension/src/wxBackend.ts
+++ b/packages/taler-wallet-webextension/src/wxBackend.ts
@@ -40,7 +40,6 @@ import {
   Wallet,
   WalletStoresV1
 } from "@gnu-taler/taler-wallet-core";
-import { VNode } from "preact";
 import { BrowserCryptoWorkerFactory } from "./browserCryptoWorkerFactory.js";
 import { BrowserHttpLib } from "./browserHttpLib.js";
 import { getReadRequestPermissions } from "./permissions.js";

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]