[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: webextension: fix useEffect d
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: webextension: fix useEffect dependency tracking |
Date: |
Wed, 08 Dec 2021 11:03:53 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 73dabdf4 webextension: fix useEffect dependency tracking
73dabdf4 is described below
commit 73dabdf43a55849ac5ca571f938d5dd847b03404
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Dec 8 11:03:50 2021 +0100
webextension: fix useEffect dependency tracking
---
packages/taler-wallet-webextension/src/cta/Pay.tsx | 5 ++++-
packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts | 9 ++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/packages/taler-wallet-webextension/src/cta/Pay.tsx
b/packages/taler-wallet-webextension/src/cta/Pay.tsx
index f1c8f270..7b7d940c 100644
--- a/packages/taler-wallet-webextension/src/cta/Pay.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Pay.tsx
@@ -134,6 +134,8 @@ export function PayPage({
const foundAmount = foundBalance
? Amounts.parseOrThrow(foundBalance.available)
: undefined;
+ // We use a string here so that dependency tracking for useEffect works
properly
+ const foundAmountStr = foundAmount ? Amounts.stringify(foundAmount) :
undefined;
useEffect(() => {
if (!talerPayUri) return;
@@ -142,6 +144,7 @@ export function PayPage({
const p = await wxApi.preparePay(talerPayUri);
setPayStatus(p);
} catch (e) {
+ console.log("Got error while trying to pay", e);
if (e instanceof OperationFailedError) {
setPayErrMsg(e);
}
@@ -151,7 +154,7 @@ export function PayPage({
}
};
doFetch();
- }, [talerPayUri, foundAmount]);
+ }, [talerPayUri, foundAmountStr]);
if (!talerPayUri) {
return <span>missing pay uri</span>;
diff --git a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts
b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts
index 38ec5bf7..e9f03d0f 100644
--- a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts
+++ b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { ExchangesListRespose, NotificationType } from "@gnu-taler/taler-util";
+import { NotificationType } from "@gnu-taler/taler-util";
import { useEffect, useState } from "preact/hooks";
import * as wxApi from "../wxApi";
@@ -30,7 +30,10 @@ interface HookError {
export type HookResponse<T> = HookOk<T> | HookError | undefined;
//"withdraw-group-finished"
-export function useAsyncAsHook<T>(fn: () => Promise<T>, updateOnNotification?:
Array<NotificationType>): HookResponse<T> {
+export function useAsyncAsHook<T>(
+ fn: () => Promise<T>,
+ updateOnNotification?: Array<NotificationType>,
+): HookResponse<T> {
const [result, setHookResponse] = useState<HookResponse<T>>(undefined);
useEffect(() => {
async function doAsync() {
@@ -46,7 +49,7 @@ export function useAsyncAsHook<T>(fn: () => Promise<T>,
updateOnNotification?: A
doAsync();
if (updateOnNotification && updateOnNotification.length > 0) {
return wxApi.onUpdateNotification(updateOnNotification, () => {
- doAsync()
+ doAsync();
});
}
}, []);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: webextension: fix useEffect dependency tracking,
gnunet <=