From b465312ceeec47f5ec011bcc46333908f5257f0d Mon Sep 17 00:00:00 2001 From: enahum Date: Mon, 5 Mar 2018 15:12:28 +0000 Subject: [PATCH] Fix edit channel (#1479) --- app/components/edit_channel_info/index.js | 2 +- app/screens/edit_channel/edit_channel.js | 14 +++++++++++--- app/screens/edit_channel/index.js | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/components/edit_channel_info/index.js b/app/components/edit_channel_info/index.js index 6d066874c..319f926de 100644 --- a/app/components/edit_channel_info/index.js +++ b/app/components/edit_channel_info/index.js @@ -213,7 +213,7 @@ export default class EditChannelInfo extends PureComponent { let displayError; if (error) { displayError = ( - + diff --git a/app/screens/edit_channel/edit_channel.js b/app/screens/edit_channel/edit_channel.js index a4fc95841..512338dbc 100644 --- a/app/screens/edit_channel/edit_channel.js +++ b/app/screens/edit_channel/edit_channel.js @@ -50,6 +50,10 @@ const messages = { export default class EditChannel extends PureComponent { static propTypes = { + actions: PropTypes.shape({ + patchChannel: PropTypes.func.isRequired, + setChannelDisplayName: PropTypes.func.isRequired, + }), navigator: PropTypes.object.isRequired, theme: PropTypes.object.isRequired, deviceWidth: PropTypes.number.isRequired, @@ -58,9 +62,6 @@ export default class EditChannel extends PureComponent { currentTeamUrl: PropTypes.string.isRequired, updateChannelRequest: PropTypes.object.isRequired, closeButton: PropTypes.object, - actions: PropTypes.shape({ - patchChannel: PropTypes.func.isRequired, - }), }; static contextTypes = { @@ -137,6 +138,13 @@ export default class EditChannel extends PureComponent { } close = () => { + const {channel: {type}} = this.props; + const isDirect = type === General.DM_CHANNEL || type === General.GM_CHANNEL; + + if (!isDirect) { + this.props.actions.setChannelDisplayName(this.state.displayName); + } + this.props.navigator.pop({animated: true}); }; diff --git a/app/screens/edit_channel/index.js b/app/screens/edit_channel/index.js index 2126bf9c4..ae1002ac5 100644 --- a/app/screens/edit_channel/index.js +++ b/app/screens/edit_channel/index.js @@ -7,8 +7,9 @@ import {connect} from 'react-redux'; import {getCurrentChannel} from 'mattermost-redux/selectors/entities/channels'; import {getCurrentTeamUrl} from 'mattermost-redux/selectors/entities/teams'; import {patchChannel} from 'mattermost-redux/actions/channels'; - import {getTheme} from 'mattermost-redux/selectors/entities/preferences'; + +import {setChannelDisplayName} from 'app/actions/views/channel'; import {getDimensions} from 'app/selectors/device'; import EditChannel from './edit_channel'; @@ -32,6 +33,7 @@ function mapDispatchToProps(dispatch) { return { actions: bindActionCreators({ patchChannel, + setChannelDisplayName, }, dispatch), }; }