From 77cfcd08137795fdf7807d03754242038d07101c Mon Sep 17 00:00:00 2001 From: rodrigopavezi Date: Thu, 19 Dec 2024 07:37:56 -0300 Subject: [PATCH 1/4] fix: improve wallet change handling in view-requests component --- .../invoice-dashboard/src/lib/view-requests.svelte | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/invoice-dashboard/src/lib/view-requests.svelte b/packages/invoice-dashboard/src/lib/view-requests.svelte index 1eb9aeb3..b0e187e6 100644 --- a/packages/invoice-dashboard/src/lib/view-requests.svelte +++ b/packages/invoice-dashboard/src/lib/view-requests.svelte @@ -119,8 +119,11 @@ cipherProvider = undefined; }; - const handleWalletChange = (data: any) => { - if (data?.address) { + const handleWalletChange = (account: GetAccountReturnType, previousAccount: GetAccountReturnType) => { + if (account?.address !== previousAccount?.address) { + handleWalletDisconnection(); + handleWalletConnection(); + } else if (account?.address) { handleWalletConnection(); } else { handleWalletDisconnection(); @@ -129,9 +132,9 @@ onMount(() => { unwatchAccount = watchAccount(wagmiConfig, { - onChange(data) { + onChange(account: GetAccountReturnType, previousAccount: GetAccountReturnType) { tick().then(() => { - handleWalletChange(data); + handleWalletChange(account, previousAccount); }); }, }); From 389e1d96efb33297bf992ec586c1e92201e3c1f8 Mon Sep 17 00:00:00 2001 From: rodrigopavezi Date: Thu, 19 Dec 2024 07:39:34 -0300 Subject: [PATCH 2/4] fix: enhance wallet change detection logic in create-invoice-form component --- .../src/lib/create-invoice-form.svelte | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/create-invoice-form/src/lib/create-invoice-form.svelte b/packages/create-invoice-form/src/lib/create-invoice-form.svelte index 59693696..7107659d 100644 --- a/packages/create-invoice-form/src/lib/create-invoice-form.svelte +++ b/packages/create-invoice-form/src/lib/create-invoice-form.svelte @@ -152,8 +152,11 @@ cipherProvider?.disconnectWallet(); }; - const handleWalletChange = (data: any) => { - if (data?.address) { + const handleWalletChange = (account: GetAccountReturnType, previousAccount: GetAccountReturnType) => { + if (account?.address !== previousAccount?.address) { + handleWalletDisconnection(); + handleWalletConnection(); + } else if (account?.address) { handleWalletConnection(); } else { handleWalletDisconnection(); @@ -162,10 +165,9 @@ onMount(() => { unwatchAccount = watchAccount(wagmiConfig, { - onChange(data) { + onChange(account: GetAccountReturnType, previousAccount: GetAccountReturnType) { tick().then(() => { - console.log("Wallet changed"); - handleWalletChange(data); + handleWalletChange(account, previousAccount); }); }, }); From 0545b871c6bcfa338479c3aecacfb790f60ed76a Mon Sep 17 00:00:00 2001 From: rodrigopavezi Date: Thu, 19 Dec 2024 07:43:06 -0300 Subject: [PATCH 3/4] chore: bump package versions for create-invoice-form to 0.11.16 and invoice-dashboard to 0.11.15 --- package-lock.json | 4 ++-- packages/create-invoice-form/package.json | 2 +- packages/invoice-dashboard/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0c3e88b5..5c99a8dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11354,7 +11354,7 @@ }, "packages/create-invoice-form": { "name": "@requestnetwork/create-invoice-form", - "version": "0.11.15", + "version": "0.11.16", "license": "MIT", "dependencies": { "@requestnetwork/data-format": "0.19.5", @@ -11374,7 +11374,7 @@ }, "packages/invoice-dashboard": { "name": "@requestnetwork/invoice-dashboard", - "version": "0.11.14", + "version": "0.11.15", "license": "MIT", "dependencies": { "@requestnetwork/payment-detection": "0.49.0", diff --git a/packages/create-invoice-form/package.json b/packages/create-invoice-form/package.json index 009eabda..ed5be910 100644 --- a/packages/create-invoice-form/package.json +++ b/packages/create-invoice-form/package.json @@ -1,6 +1,6 @@ { "name": "@requestnetwork/create-invoice-form", - "version": "0.11.15", + "version": "0.11.16", "main": "./dist/web-component.umd.cjs", "scripts": { "dev": "vite dev", diff --git a/packages/invoice-dashboard/package.json b/packages/invoice-dashboard/package.json index e56046d5..b970e96c 100644 --- a/packages/invoice-dashboard/package.json +++ b/packages/invoice-dashboard/package.json @@ -1,6 +1,6 @@ { "name": "@requestnetwork/invoice-dashboard", - "version": "0.11.14", + "version": "0.11.15", "main": "./dist/web-component.umd.cjs", "scripts": { "dev": "vite dev", From 81dca3d4c7b816709ad224a2a599d720f04c6563 Mon Sep 17 00:00:00 2001 From: rodrigopavezi Date: Thu, 19 Dec 2024 07:56:47 -0300 Subject: [PATCH 4/4] fix: add loading state management in view-requests component --- packages/invoice-dashboard/src/lib/view-requests.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/invoice-dashboard/src/lib/view-requests.svelte b/packages/invoice-dashboard/src/lib/view-requests.svelte index b0e187e6..5c5742fe 100644 --- a/packages/invoice-dashboard/src/lib/view-requests.svelte +++ b/packages/invoice-dashboard/src/lib/view-requests.svelte @@ -163,7 +163,7 @@ requestNetwork: RequestNetwork | undefined | null ) => { if (!account?.address || !requestNetwork) return; - + loading = true; try { const requestsData = await requestNetwork?.fromIdentity({ type: Types.Identity.TYPE.ETHEREUM_ADDRESS, @@ -174,6 +174,8 @@ .sort((a, b) => b.timestamp - a.timestamp); } catch (error) { console.error("Failed to fetch requests:", error); + } finally { + loading = false; } };