From cbda3f7bf10641861922fe9a2a345d27e22d4c08 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Thu, 10 Nov 2022 00:36:56 +0000 Subject: [PATCH] feat: mark notifications as read when acknowledged --- client/src/app/pages/dashboard/users/NotificationsPage.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/src/app/pages/dashboard/users/NotificationsPage.tsx b/client/src/app/pages/dashboard/users/NotificationsPage.tsx index d500ea08a..dbda57464 100644 --- a/client/src/app/pages/dashboard/users/NotificationsPage.tsx +++ b/client/src/app/pages/dashboard/users/NotificationsPage.tsx @@ -36,6 +36,13 @@ function NotificationsInnerPage({ user }: { user: UserDocument }) { return data.filter((e) => e.read === false).length; }, [data]); + // mark all notifications the user has seen as being read + useEffect(() => { + if (data) { + APIFetchV1(`/users/${user.id}/notifications/mark-all-read`, { method: "POST" }); + } + }, [data]); + if (error) { return ; }