Skip to content

Commit

Permalink
Merge pull request #25521 from tienifr/fix/23958
Browse files Browse the repository at this point in the history
fix: 23958 reload attachment preview and close, app displays random chat for few seconds
  • Loading branch information
cristipaval authored Aug 25, 2023
2 parents 34d4e54 + 73cb5d4 commit f3b5299
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,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/,
ILLEGAL_FILENAME_CHARACTERS: /\/|<|>|\*|"|:|\?|\\|\|/g,
},

Expand Down
10 changes: 10 additions & 0 deletions src/libs/Navigation/AppNavigator/ReportScreenWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -61,6 +63,14 @@ 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;
}

const lastReport = ReportUtils.findLastAccessedReport(reports, ignoreDefaultRooms, policies, isFirstTimeNewExpensifyUser, openOnAdminRoom);

return lodashGet(lastReport, 'reportID');
Expand Down

0 comments on commit f3b5299

Please sign in to comment.