Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/libs/Navigation/AppNavigator/MainDrawerNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import Permissions from '../../Permissions';
import Timing from '../../actions/Timing';
import CONST from '../../../CONST';
import * as App from '../../actions/App';
import * as Report from '../../actions/Report';
import * as Session from '../../actions/Session';

// Screens
import ReportScreen from '../../../pages/home/ReportScreen';
Expand Down Expand Up @@ -38,6 +40,9 @@ const propTypes = {
}),
),

/** The report ID of the last opened public room as anonymous user */
lastOpenedPublicRoomID: PropTypes.string,

isFirstTimeNewExpensifyUser: PropTypes.bool,

route: PropTypes.shape({
Expand All @@ -54,6 +59,7 @@ const defaultProps = {
betas: [],
policies: {},
isFirstTimeNewExpensifyUser: false,
lastOpenedPublicRoomID: null,
};

/**
Expand Down Expand Up @@ -91,6 +97,15 @@ class MainDrawerNavigator extends Component {
this.isFromCache = _.size(props.reports) > 0;
}

componentDidMount() {
if (!this.props.lastOpenedPublicRoomID || Session.isAnonymousUser()) {
return;
}
// Re-open the last opened public room if the user logged in
Report.setLastOpenedPublicRoom('');
Report.openReport(this.props.lastOpenedPublicRoomID);
}

shouldComponentUpdate(nextProps) {
const initialNextParams = getInitialReportScreenParams(
nextProps.reports,
Expand Down Expand Up @@ -172,4 +187,7 @@ export default withOnyx({
isFirstTimeNewExpensifyUser: {
key: ONYXKEYS.NVP_IS_FIRST_TIME_NEW_EXPENSIFY_USER,
},
lastOpenedPublicRoomID: {
key: ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID,
},
})(MainDrawerNavigator);
15 changes: 0 additions & 15 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import * as EmojiPickerAction from '../../libs/actions/EmojiPickerAction';
import TaskHeader from '../../components/TaskHeader';
import MoneyRequestHeader from '../../components/MoneyRequestHeader';
import * as ComposerActions from '../../libs/actions/Composer';
import * as Session from '../../libs/actions/Session';

const propTypes = {
/** Navigation route context info provided by react navigation */
Expand Down Expand Up @@ -84,9 +83,6 @@ const propTypes = {
/** The account manager report ID */
accountManagerReportID: PropTypes.string,

/** The report ID of the last opened public room as anonymous user */
lastOpenedPublicRoomID: PropTypes.string,

/** All of the personal details for everyone */
personalDetails: PropTypes.objectOf(personalDetailsPropType),

Expand All @@ -107,7 +103,6 @@ const defaultProps = {
policies: {},
accountManagerReportID: null,
personalDetails: {},
lastOpenedPublicRoomID: null,
};

/**
Expand Down Expand Up @@ -198,13 +193,6 @@ class ReportScreen extends React.Component {
}

fetchReportIfNeeded() {
// Re-open the last opened public room if the user logged in
if (this.props.lastOpenedPublicRoomID && !Session.isAnonymousUser()) {
Report.setLastOpenedPublicRoom('');
Report.openReport(this.props.lastOpenedPublicRoomID);
return;
}

const reportIDFromPath = getReportID(this.props.route);

// Report ID will be empty when the reports collection is empty.
Expand Down Expand Up @@ -400,9 +388,6 @@ export default compose(
withDrawerState,
withNetwork(),
withOnyx({
lastOpenedPublicRoomID: {
key: ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID,
},
isSidebarLoaded: {
key: ONYXKEYS.IS_SIDEBAR_LOADED,
},
Expand Down