From 54d4330a97963b656113739eea9244dd583e609b Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Sun, 13 Oct 2024 21:25:59 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9(frontend)=20clean=20up=20notificat?= =?UTF-8?q?ions=20when=20participant=20quits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a participant leaves a videoconference, remove all notifications they authored. It's generally unnecessary to keep notifications about actions from users who are no longer present, with few exceptions. As we currently support only two notification types (Joined and Raised Hand), it's appropriate to close all of them when the author leaves the room. --- .../notifications/MainNotificationToast.tsx | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/frontend/src/features/notifications/MainNotificationToast.tsx b/src/frontend/src/features/notifications/MainNotificationToast.tsx index f6bc0dd8..e482419a 100644 --- a/src/frontend/src/features/notifications/MainNotificationToast.tsx +++ b/src/frontend/src/features/notifications/MainNotificationToast.tsx @@ -34,19 +34,19 @@ export const MainNotificationToast = () => { }, [room, triggerNotificationSound]) useEffect(() => { - const removeJoinNotification = (participant: Participant) => { - const existingToast = toastQueue.visibleToasts.find( - (toast) => - toast.content.participant === participant && - toast.content.type === NotificationType.Joined - ) - if (existingToast) { - toastQueue.close(existingToast.key) - } + const removeParticipantNotifications = (participant: Participant) => { + toastQueue.visibleToasts.forEach((toast) => { + if (toast.content.participant === participant) { + toastQueue.close(toast.key) + } + }) } - room.on(RoomEvent.ParticipantDisconnected, removeJoinNotification) + room.on(RoomEvent.ParticipantDisconnected, removeParticipantNotifications) return () => { - room.off(RoomEvent.ParticipantConnected, removeJoinNotification) + room.off( + RoomEvent.ParticipantDisconnected, + removeParticipantNotifications + ) } }, [room])