Skip to content

Commit

Permalink
move clearing notification logic to ReportScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
arosiclair committed Dec 18, 2023
1 parent ae53577 commit 7271668
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
3 changes: 0 additions & 3 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import * as Environment from '@libs/Environment/Environment';
import * as ErrorUtils from '@libs/ErrorUtils';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import clearReportNotifications from '@libs/Notification/clearReportNotifications';
import LocalNotification from '@libs/Notification/LocalNotification';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
Expand Down Expand Up @@ -475,8 +474,6 @@ function openReport(
return;
}

clearReportNotifications(reportID);

const optimisticReport = reportActionsExist(reportID)
? {}
: {
Expand Down
20 changes: 10 additions & 10 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,17 @@ function ReportScreen({
[route],
);

// Clear notifications for the current report when the app is focused
useAppFocusEvent(
useCallback(() => {
// Check if this is the top-most ReportScreen since the Navigator preserves multiple at a time
if (!isTopMostReportId) {
return;
}
// Clear notifications for the current report when it's opened and re-focused
const clearNotifications = useCallback(() => {
// Check if this is the top-most ReportScreen since the Navigator preserves multiple at a time
if (!isTopMostReportId) {
return;
}

clearReportNotifications(report.reportID);
}, [report.reportID, isTopMostReportId]),
);
clearReportNotifications(report.reportID);
}, [report.reportID, isTopMostReportId]);
useEffect(clearNotifications, [clearNotifications]);
useAppFocusEvent(clearNotifications);

useEffect(() => {
Timing.end(CONST.TIMING.CHAT_RENDER);
Expand Down

0 comments on commit 7271668

Please sign in to comment.