From 729de3f8eb03d6589dfa2b582de9eddd58c0d49b Mon Sep 17 00:00:00 2001 From: tienifr Date: Sat, 19 Aug 2023 16:53:53 +0700 Subject: [PATCH 1/2] fix: 23958 reload attachment preview and close, app displays random chat for few seconds --- src/CONST.js | 1 + src/libs/Navigation/AppNavigator/ReportScreenWrapper.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/CONST.js b/src/CONST.js index e7d2fa6f4d03..50fa7e582753 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -1176,6 +1176,7 @@ const CONST = { TIME_STARTS_01: /^01:\d{2} [AP]M$/, TIME_FORMAT: /^\d{2}:\d{2} [AP]M$/, DATE_TIME_FORMAT: /^\d{2}-\d{2} \d{2}:\d{2} [AP]M$/, + ATTACHMENT_ROUTE: /\/r\/(\d*)\/attachment/, }, PRONOUNS: { diff --git a/src/libs/Navigation/AppNavigator/ReportScreenWrapper.js b/src/libs/Navigation/AppNavigator/ReportScreenWrapper.js index b5bbaf91c152..43267dcd5a90 100644 --- a/src/libs/Navigation/AppNavigator/ReportScreenWrapper.js +++ b/src/libs/Navigation/AppNavigator/ReportScreenWrapper.js @@ -11,6 +11,8 @@ import reportPropTypes from '../../../pages/reportPropTypes'; import {withNavigationPropTypes} from '../../../components/withNavigation'; import * as App from '../../actions/App'; import usePermissions from '../../../hooks/usePermissions'; +import CONST from '../../../CONST'; +import Navigation from '../Navigation'; const propTypes = { /** Available reports that would be displayed in this navigator */ @@ -61,6 +63,11 @@ const defaultProps = { * @returns {Number} */ const getLastAccessedReportID = (reports, ignoreDefaultRooms, policies, isFirstTimeNewExpensifyUser, openOnAdminRoom) => { + const currentRoute = Navigation.getActiveRoute(); + const matches = CONST.REGEX.ATTACHMENT_ROUTE.exec(currentRoute); + const reportID = lodashGet(matches, 1, null); + if (reportID) return reportID; + const lastReport = ReportUtils.findLastAccessedReport(reports, ignoreDefaultRooms, policies, isFirstTimeNewExpensifyUser, openOnAdminRoom); return lodashGet(lastReport, 'reportID'); From 03d513717a284671eee3b3cd7f1c63a8db54dda2 Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 23 Aug 2023 15:16:26 +0700 Subject: [PATCH 2/2] add comments --- src/libs/Navigation/AppNavigator/ReportScreenWrapper.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/ReportScreenWrapper.js b/src/libs/Navigation/AppNavigator/ReportScreenWrapper.js index 43267dcd5a90..f1743e1a2269 100644 --- a/src/libs/Navigation/AppNavigator/ReportScreenWrapper.js +++ b/src/libs/Navigation/AppNavigator/ReportScreenWrapper.js @@ -63,10 +63,13 @@ const defaultProps = { * @returns {Number} */ const getLastAccessedReportID = (reports, ignoreDefaultRooms, policies, isFirstTimeNewExpensifyUser, openOnAdminRoom) => { + // If deeplink url is of an attachment, we should show the report that the attachment comes from. const currentRoute = Navigation.getActiveRoute(); const matches = CONST.REGEX.ATTACHMENT_ROUTE.exec(currentRoute); const reportID = lodashGet(matches, 1, null); - if (reportID) return reportID; + if (reportID) { + return reportID; + } const lastReport = ReportUtils.findLastAccessedReport(reports, ignoreDefaultRooms, policies, isFirstTimeNewExpensifyUser, openOnAdminRoom);