From 68b4a27c81f705aa3bb6dadde6bf4b9cf95631d6 Mon Sep 17 00:00:00 2001 From: aokiji233 Date: Fri, 23 Aug 2024 18:56:45 +0200 Subject: [PATCH 1/3] fix: side effect causing notifcations glitch --- components/UI/notifications/notificationDetail.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/UI/notifications/notificationDetail.tsx b/components/UI/notifications/notificationDetail.tsx index 8db53324..d8494ce3 100644 --- a/components/UI/notifications/notificationDetail.tsx +++ b/components/UI/notifications/notificationDetail.tsx @@ -79,7 +79,7 @@ const NotificationDetail: FunctionComponent = ({ if (status !== notification.data.status) { updateNotificationStatus(notification.data.hash, status); } - }, [notification, isLoading, error, isError, data, status]); + }, [ isLoading, error, isError, data, status]); return (
From b23c44086c13ccf0691cad9b05d3d8f1d67ca7b9 Mon Sep 17 00:00:00 2001 From: aokiji233 Date: Fri, 23 Aug 2024 19:22:14 +0200 Subject: [PATCH 2/3] remove log --- hooks/useNotificationManager.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/hooks/useNotificationManager.ts b/hooks/useNotificationManager.ts index 68b2838e..79bfd92c 100644 --- a/hooks/useNotificationManager.ts +++ b/hooks/useNotificationManager.ts @@ -27,7 +27,6 @@ export function useNotificationManager() { ); notifications[index].data.status = status; setNotifications(notifications); - console.log("notifications", notifications); }; const checkTransactionStatus = async (txHash: string) => { From 320ff726603319183ff5eb38c902a9943a871666 Mon Sep 17 00:00:00 2001 From: aokiji233 Date: Fri, 23 Aug 2024 19:28:24 +0200 Subject: [PATCH 3/3] improve update notification set --- hooks/useNotificationManager.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hooks/useNotificationManager.ts b/hooks/useNotificationManager.ts index 79bfd92c..ea3306ab 100644 --- a/hooks/useNotificationManager.ts +++ b/hooks/useNotificationManager.ts @@ -22,11 +22,20 @@ export function useNotificationManager() { txHash: string, status: "error" | "pending" | "success" ) => { - const index = notifications.findIndex( - (notification) => notification.data.hash === txHash - ); - notifications[index].data.status = status; - setNotifications(notifications); + const updatedNotifications = notifications.map((notification) => { + if (notification.data.hash === txHash) { + return { + ...notification, + data: { + ...notification.data, + status, + }, + }; + } + return notification; + }); + + setNotifications(updatedNotifications); }; const checkTransactionStatus = async (txHash: string) => {