Skip to content

Commit

Permalink
improve update notification set
Browse files Browse the repository at this point in the history
  • Loading branch information
aokiji233 committed Aug 23, 2024
1 parent b23c440 commit 320ff72
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions hooks/useNotificationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 320ff72

Please sign in to comment.