Skip to content

Commit

Permalink
Merge pull request #33254 from Expensify/arosiclair-clear-notif-cycle
Browse files Browse the repository at this point in the history
Fix require cycle from clearReportNotifications
  • Loading branch information
jasperhuangg authored Dec 20, 2023
2 parents 86d72e0 + 7271668 commit 3ab2de7
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 @@ -17,7 +17,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 @@ -477,8 +476,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 @@ -299,17 +299,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 3ab2de7

Please sign in to comment.