Fix channel editing for DM and GM channels (#1276)

This commit is contained in:
enahum 2017-12-07 12:16:45 -03:00 committed by GitHub
parent 6e3e03bf18
commit 4b20dc5e66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,7 +9,7 @@ import {
InteractionManager
} from 'react-native';
import {RequestStatus} from 'mattermost-redux/constants';
import {General, RequestStatus} from 'mattermost-redux/constants';
import EventEmitter from 'mattermost-redux/utils/event_emitter';
import EditChannelInfo from 'app/components/edit_channel_info';
@ -199,23 +199,27 @@ export default class EditChannel extends PureComponent {
onUpdateChannel = () => {
Keyboard.dismiss();
const {displayName, channelURL, purpose, header} = this.state;
const {channel: {id}} = this.props;
const {channel: {id, type}} = this.props;
const isDirect = type === General.DM_CHANNEL || type === General.GM_CHANNEL;
const channel = {
display_name: displayName,
display_name: isDirect ? '' : displayName,
name: channelURL,
purpose,
header
};
let result = this.validateDisplayName(displayName.trim());
if (result.error) {
this.setState({error: result.error});
return;
}
result = this.validateChannelURL(channelURL.trim());
if (result.error) {
this.setState({error: result.error});
return;
if (!isDirect) {
let result = this.validateDisplayName(displayName.trim());
if (result.error) {
this.setState({error: result.error});
return;
}
result = this.validateChannelURL(channelURL.trim());
if (result.error) {
this.setState({error: result.error});
return;
}
}
this.props.actions.patchChannel(id, channel);