From 7271668d3bef91cc0c681a32cb927e94c98db4cd Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Mon, 18 Dec 2023 15:31:33 -0500 Subject: [PATCH] move clearing notification logic to ReportScreen --- src/libs/actions/Report.ts | 3 --- src/pages/home/ReportScreen.js | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index c3b1532b4d87..a13e1e34eea9 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -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'; @@ -475,8 +474,6 @@ function openReport( return; } - clearReportNotifications(reportID); - const optimisticReport = reportActionsExist(reportID) ? {} : { diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 161b8aa8889d..6ad68af4577c 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -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);