Skip to content

Commit

Permalink
feat(courses): add clear notifications when leave directory file view
Browse files Browse the repository at this point in the history
  • Loading branch information
miky41195 committed Mar 3, 2025
1 parent 1ce8185 commit 9144112
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/features/courses/screens/CourseDirectoryScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { NativeStackScreenProps } from '@react-navigation/native-stack';

import { DateTime } from 'luxon';

import { useNotifications } from '../../../../src/core/hooks/useNotifications';
import { useOnLeaveScreen } from '../../../../src/core/hooks/useOnLeaveScreen';
import { BottomBarSpacer } from '../../../core/components/BottomBarSpacer';
import { usePreferencesContext } from '../../../core/contexts/PreferencesContext';
import { useSafeAreaSpacing } from '../../../core/hooks/useSafeAreaSpacing';
Expand Down Expand Up @@ -64,6 +66,11 @@ export const CourseDirectoryScreen = ({ route, navigation }: Props) => {
const directoryQuery = useGetCourseDirectory(courseId, directoryId);
const { paddingHorizontal } = useSafeAreaSpacing();
const { updatePreference } = usePreferencesContext();
const { clearNotificationScope } = useNotifications();

useOnLeaveScreen(() => {
clearNotificationScope(['teaching', 'courses', courseId, 'files']);
});

useEffect(() => {
if (navigation.getId() !== 'FileTabNavigator') {
Expand All @@ -77,7 +84,6 @@ export const CourseDirectoryScreen = ({ route, navigation }: Props) => {
if (a.type !== 'directory' && b.type !== 'directory') {
const dateA = DateTime.fromJSDate(a.createdAt).startOf('minute');
const dateB = DateTime.fromJSDate(b.createdAt).startOf('minute');

if (dateA.equals(dateB)) {
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
}
Expand Down

0 comments on commit 9144112

Please sign in to comment.