From 5b282b62e7a5fc3766e61da69f789f4ee134d328 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 16 Sep 2024 11:16:41 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9(frontend)=20dismiss=20notification?= =?UTF-8?q?=20toasts=20on=20room=20disconnect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure notification toasts are cleared when a participant disconnects, preventing stale notifications from showing if the user quickly rejoins. This resolves issues with duplicate or outdated notifications appearing. --- .../features/notifications/MainNotificationToast.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/frontend/src/features/notifications/MainNotificationToast.tsx b/src/frontend/src/features/notifications/MainNotificationToast.tsx index 50739f78..0ff7a526 100644 --- a/src/frontend/src/features/notifications/MainNotificationToast.tsx +++ b/src/frontend/src/features/notifications/MainNotificationToast.tsx @@ -93,6 +93,16 @@ export const MainNotificationToast = () => { } }, [room, triggerNotificationSound]) + useEffect(() => { + const closeAllToasts = () => { + toastQueue.visibleToasts.forEach(({ key }) => toastQueue.close(key)) + } + room.on(RoomEvent.Disconnected, closeAllToasts) + return () => { + room.off(RoomEvent.Disconnected, closeAllToasts) + } + }, [room]) + return (