From 02cc12314ad29f0e6221f9bdcb8704b939e36b66 Mon Sep 17 00:00:00 2001 From: Umberto Pepato Date: Tue, 30 Jan 2024 19:12:25 +0100 Subject: [PATCH] feat(notifications): ensure course notices notifs cleared on screen blur --- .../courses/screens/CourseNoticesScreen.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/features/courses/screens/CourseNoticesScreen.tsx b/src/features/courses/screens/CourseNoticesScreen.tsx index fba53a72..29547341 100644 --- a/src/features/courses/screens/CourseNoticesScreen.tsx +++ b/src/features/courses/screens/CourseNoticesScreen.tsx @@ -15,6 +15,7 @@ import { BottomBarSpacer } from '../../../core/components/BottomBarSpacer'; import { useAccessibility } from '../../../core/hooks/useAccessibilty'; import { useNotifications } from '../../../core/hooks/useNotifications'; import { useOfflineDisabled } from '../../../core/hooks/useOfflineDisabled'; +import { useOnLeaveScreen } from '../../../core/hooks/useOnLeaveScreen'; import { useSafeAreaSpacing } from '../../../core/hooks/useSafeAreaSpacing'; import { useGetCourseNotices } from '../../../core/queries/courseHooks'; import { GlobalStyles } from '../../../core/styles/GlobalStyles'; @@ -41,12 +42,14 @@ export const CourseNoticesScreen = () => { })) ?? [], [noticesQuery], ); - const noticesNotificationScope = [ - 'teaching', - 'courses', - courseId.toString(), - 'notices', - ]; + const noticesNotificationScope = useMemo( + () => ['teaching', 'courses', courseId.toString(), 'notices'], + [courseId], + ); + + useOnLeaveScreen(() => { + clearNotificationScope(noticesNotificationScope); + }); return (