diff --git a/src/screens/AssignmentScreen.tsx b/src/screens/AssignmentScreen.tsx index 93dc021e..1b37f74c 100644 --- a/src/screens/AssignmentScreen.tsx +++ b/src/screens/AssignmentScreen.tsx @@ -268,19 +268,18 @@ const AssignmentScreen: INavigationScreen = (props) => { const assignment = JSON.parse( data.assignment as string, ) as WithCourseInfo; - if (!assignments.find((n) => n.id === assignment.id)) { - dispatch( - getAssignmentsForCourseAction.success({ - assignments: [ - assignment, - ...assignments.filter( - (i) => i.courseId === assignment.courseId, - ), - ], - courseId: assignment.courseId, - }), - ); - } + dispatch( + getAssignmentsForCourseAction.success({ + assignments: [ + assignment, + ...assignments.filter( + (i) => + i.courseId === assignment.courseId && i.id !== assignment.id, + ), + ], + courseId: assignment.courseId, + }), + ); } }); return () => sub.remove(); @@ -295,19 +294,18 @@ const AssignmentScreen: INavigationScreen = (props) => { const assignment = JSON.parse( data.assignment as string, ) as WithCourseInfo; - if (!assignments.find((n) => n.id === assignment.id)) { - dispatch( - getAssignmentsForCourseAction.success({ - assignments: [ - assignment, - ...assignments.filter( - (i) => i.courseId === assignment.courseId, - ), - ], - courseId: assignment.courseId, - }), - ); - } + dispatch( + getAssignmentsForCourseAction.success({ + assignments: [ + assignment, + ...assignments.filter( + (i) => + i.courseId === assignment.courseId && i.id !== assignment.id, + ), + ], + courseId: assignment.courseId, + }), + ); Navigation.mergeOptions(props.componentId, { bottomTabs: { currentTabIndex: 2, diff --git a/src/screens/FileScreen.tsx b/src/screens/FileScreen.tsx index d09f1f23..eb9dfab3 100644 --- a/src/screens/FileScreen.tsx +++ b/src/screens/FileScreen.tsx @@ -221,17 +221,17 @@ const FileScreen: INavigationScreen = (props) => { e.request.content.data ?? (e.request.trigger as any).remoteMessage.data; if (data?.file) { const file = JSON.parse(data.file as string) as WithCourseInfo; - if (!files.find((n) => n.id === file.id)) { - dispatch( - getFilesForCourseAction.success({ - files: [ - file, - ...files.filter((i) => i.courseId === file.courseId), - ], - courseId: file.courseId, - }), - ); - } + dispatch( + getFilesForCourseAction.success({ + files: [ + file, + ...files.filter( + (i) => i.courseId === file.courseId && i.id !== file.id, + ), + ], + courseId: file.courseId, + }), + ); } }); return () => sub.remove(); @@ -244,17 +244,17 @@ const FileScreen: INavigationScreen = (props) => { (e.notification.request.trigger as any).remoteMessage.data; if (data?.file) { const file = JSON.parse(data.file as string) as WithCourseInfo; - if (!files.find((n) => n.id === file.id)) { - dispatch( - getFilesForCourseAction.success({ - files: [ - file, - ...files.filter((i) => i.courseId === file.courseId), - ], - courseId: file.courseId, - }), - ); - } + dispatch( + getFilesForCourseAction.success({ + files: [ + file, + ...files.filter( + (i) => i.courseId === file.courseId && i.id !== file.id, + ), + ], + courseId: file.courseId, + }), + ); Navigation.mergeOptions(props.componentId, { bottomTabs: { currentTabIndex: 1, diff --git a/src/screens/NoticeScreen.tsx b/src/screens/NoticeScreen.tsx index 2e0e5b31..9aaed2c5 100644 --- a/src/screens/NoticeScreen.tsx +++ b/src/screens/NoticeScreen.tsx @@ -346,17 +346,17 @@ const NoticeScreen: INavigationScreen = (props) => { const notice = JSON.parse(data.notice as string) as WithCourseInfo< INotice >; - if (!notices.find((n) => n.id === notice.id)) { - dispatch( - getNoticesForCourseAction.success({ - notices: [ - notice, - ...notices.filter((i) => i.courseId === notice.courseId), - ], - courseId: notice.courseId, - }), - ); - } + dispatch( + getNoticesForCourseAction.success({ + notices: [ + notice, + ...notices.filter( + (i) => i.courseId === notice.courseId && i.id !== notice.id, + ), + ], + courseId: notice.courseId, + }), + ); } }); return () => sub.remove(); @@ -371,17 +371,17 @@ const NoticeScreen: INavigationScreen = (props) => { const notice = JSON.parse(data.notice as string) as WithCourseInfo< INotice >; - if (!notices.find((n) => n.id === notice.id)) { - dispatch( - getNoticesForCourseAction.success({ - notices: [ - notice, - ...notices.filter((i) => i.courseId === notice.courseId), - ], - courseId: notice.courseId, - }), - ); - } + dispatch( + getNoticesForCourseAction.success({ + notices: [ + notice, + ...notices.filter( + (i) => i.courseId === notice.courseId && i.id !== notice.id, + ), + ], + courseId: notice.courseId, + }), + ); Navigation.mergeOptions(props.componentId, { bottomTabs: { currentTabIndex: 0,