From 0a93ec134c1bcfb467dae1b8578e5a75d3bd49bf Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Tue, 23 Jul 2019 18:16:33 +0200 Subject: [PATCH] User popToRoot over resetToChannel (#3018) --- app/screens/user_profile/index.js | 6 ++++-- app/screens/user_profile/user_profile.js | 11 +++++------ app/screens/user_profile/user_profile.test.js | 7 +++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/screens/user_profile/index.js b/app/screens/user_profile/index.js index f4e926c61..01c5c91e6 100644 --- a/app/screens/user_profile/index.js +++ b/app/screens/user_profile/index.js @@ -18,8 +18,9 @@ import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; import { setButtons, dismissModal, - resetToChannel, goToScreen, + dismissAllModals, + popToRoot, } from 'app/actions/navigation'; import UserProfile from './user_profile'; @@ -52,8 +53,9 @@ function mapDispatchToProps(dispatch) { loadBot, setButtons, dismissModal, - resetToChannel, goToScreen, + dismissAllModals, + popToRoot, }, dispatch), }; } diff --git a/app/screens/user_profile/user_profile.js b/app/screens/user_profile/user_profile.js index a22fd75ff..5bc47ee7d 100644 --- a/app/screens/user_profile/user_profile.js +++ b/app/screens/user_profile/user_profile.js @@ -37,8 +37,9 @@ export default class UserProfile extends PureComponent { loadBot: PropTypes.func.isRequired, setButtons: PropTypes.func.isRequired, dismissModal: PropTypes.func.isRequired, - resetToChannel: PropTypes.func.isRequired, goToScreen: PropTypes.func.isRequired, + dismissAllModals: PropTypes.func.isRequired, + popToRoot: PropTypes.func.isRequired, }).isRequired, componentId: PropTypes.string, config: PropTypes.object.isRequired, @@ -102,17 +103,15 @@ export default class UserProfile extends PureComponent { } close = () => { - const {actions, fromSettings} = this.props; + const {actions, fromSettings, componentId} = this.props; if (fromSettings) { actions.dismissModal(); return; } - const passProps = { - disableTermsModal: true, - }; - actions.resetToChannel(passProps); + actions.dismissAllModals(); + actions.popToRoot(componentId); }; getDisplayName = () => { diff --git a/app/screens/user_profile/user_profile.test.js b/app/screens/user_profile/user_profile.test.js index a8dba3122..4f8bc98d2 100644 --- a/app/screens/user_profile/user_profile.test.js +++ b/app/screens/user_profile/user_profile.test.js @@ -25,8 +25,9 @@ describe('user_profile', () => { loadBot: jest.fn(), setButtons: jest.fn(), dismissModal: jest.fn(), - resetToChannel: jest.fn(), goToScreen: jest.fn(), + dismissAllModals: jest.fn(), + popToRoot: jest.fn(), }; const baseProps = { actions, @@ -171,6 +172,8 @@ describe('user_profile', () => { props.fromSettings = false; wrapper.setProps({...props}); wrapper.instance().navigationButtonPressed(event); - expect(props.actions.resetToChannel).toHaveBeenCalledTimes(1); + expect(props.actions.dismissAllModals).toHaveBeenCalledTimes(1); + expect(props.actions.popToRoot).toHaveBeenCalledTimes(1); + expect(props.actions.popToRoot).toHaveBeenCalledWith(props.componentId); }); });