Skip to content

Commit

Permalink
Merge pull request #829 from aokiji233/fix/notifications-glitch
Browse files Browse the repository at this point in the history
Fix/notifications glitch
  • Loading branch information
Marchand-Nicolas authored Aug 24, 2024
2 parents 44cc26c + 320ff72 commit d691210
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/UI/notifications/notificationDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const NotificationDetail: FunctionComponent<NotificationDetailProps> = ({
if (status !== notification.data.status) {
updateNotificationStatus(notification.data.hash, status);
}
}, [notification, isLoading, error, isError, data, status]);
}, [ isLoading, error, isError, data, status]);

return (
<div className={styles.notif_detail}>
Expand Down
20 changes: 14 additions & 6 deletions hooks/useNotificationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +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);
console.log("notifications", 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 d691210

Please sign in to comment.