Skip to content

Commit

Permalink
Merge pull request #10069 from ntdiary/issue-9253
Browse files Browse the repository at this point in the history
Fix Issue 9253: Previous chat username is displayed when you navigate back from different chat
  • Loading branch information
AndrewGable authored Aug 10, 2022
2 parents 02f8376 + 7e4242e commit 972b835
Showing 1 changed file with 41 additions and 28 deletions.
69 changes: 41 additions & 28 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Keyboard, View} from 'react-native';
import lodashGet from 'lodash/get';
import _ from 'underscore';
import lodashFindLast from 'lodash/findLast';
import DrawerStatusContext from '@react-navigation/drawer/lib/module/utils/DrawerStatusContext';
import styles from '../../styles/styles';
import ScreenWrapper from '../../components/ScreenWrapper';
import HeaderView from './HeaderView';
Expand All @@ -26,6 +27,7 @@ import addViewportResizeListener from '../../libs/VisualViewport';
import {withNetwork} from '../../components/OnyxProvider';
import compose from '../../libs/compose';
import networkPropTypes from '../../components/networkPropTypes';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../components/withWindowDimensions';

const propTypes = {
/** Navigation route context info provided by react navigation */
Expand Down Expand Up @@ -83,6 +85,8 @@ const propTypes = {

/** Information about the network */
network: networkPropTypes.isRequired,

...windowDimensionsPropTypes,
};

const defaultProps = {
Expand Down Expand Up @@ -194,6 +198,10 @@ class ReportScreen extends React.Component {
return null;
}

if (this.props.isSmallScreenWidth && this.context === 'open') {
return null;
}

// We let Free Plan default rooms to be shown in the App - it's the one exception to the beta, otherwise do not show policy rooms in product
if (!Permissions.canUseDefaultRooms(this.props.betas)
&& ReportUtils.isDefaultRoom(this.props.report)
Expand Down Expand Up @@ -268,34 +276,39 @@ class ReportScreen extends React.Component {
}
}

ReportScreen.contextType = DrawerStatusContext;
ReportScreen.propTypes = propTypes;
ReportScreen.defaultProps = defaultProps;

export default compose(withNetwork(), withOnyx({
isSidebarLoaded: {
key: ONYXKEYS.IS_SIDEBAR_LOADED,
},
session: {
key: ONYXKEYS.SESSION,
},
reportActions: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getReportID(route)}`,
canEvict: false,
},
report: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${getReportID(route)}`,
},
isComposerFullSize: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${getReportID(route)}`,
},
betas: {
key: ONYXKEYS.BETAS,
},
isLoadingInitialReportActions: {
key: ({route}) => `${ONYXKEYS.COLLECTION.IS_LOADING_INITIAL_REPORT_ACTIONS}${getReportID(route)}`,
initWithStoredValues: false,
},
policies: {
key: ONYXKEYS.COLLECTION.POLICY,
},
}))(ReportScreen);
export default compose(
withWindowDimensions,
withNetwork(),
withOnyx({
isSidebarLoaded: {
key: ONYXKEYS.IS_SIDEBAR_LOADED,
},
session: {
key: ONYXKEYS.SESSION,
},
reportActions: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getReportID(route)}`,
canEvict: false,
},
report: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${getReportID(route)}`,
},
isComposerFullSize: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${getReportID(route)}`,
},
betas: {
key: ONYXKEYS.BETAS,
},
isLoadingInitialReportActions: {
key: ({route}) => `${ONYXKEYS.COLLECTION.IS_LOADING_INITIAL_REPORT_ACTIONS}${getReportID(route)}`,
initWithStoredValues: false,
},
policies: {
key: ONYXKEYS.COLLECTION.POLICY,
},
}),
)(ReportScreen);

0 comments on commit 972b835

Please sign in to comment.