diff --git a/app/components/post_textbox/post_textbox.js b/app/components/post_textbox/post_textbox.js index 07c7d27c0..b32c4ed73 100644 --- a/app/components/post_textbox/post_textbox.js +++ b/app/components/post_textbox/post_textbox.js @@ -374,7 +374,7 @@ class PostTextbox extends PureComponent { }; render() { - const {channelIsLoading, intl, theme, value} = this.props; + const {channelIsLoading, config, intl, theme, value} = this.props; const style = getStyleSheet(theme); const textInputHeight = Math.min(this.state.contentHeight, MAX_CONTENT_HEIGHT); @@ -390,7 +390,7 @@ class PostTextbox extends PureComponent { let fileUpload = null; const inputContainerStyle = [style.inputContainer]; - if (this.props.config.EnableFileAttachments === 'true') { + if (!config.EnableFileAttachments || config.EnableFileAttachments === 'true') { fileUpload = ( { + const {actions, currentTeamId, currentUserId} = this.props; + const {channels} = this.state; + this.emitCanCreateChannel(false); this.setState({adding: true}); - await this.props.actions.joinChannel( - this.props.currentUserId, - this.props.currentTeamId, - id); - await this.props.actions.handleSelectChannel(id); + await actions.joinChannel(currentUserId, currentTeamId, id); + + const channel = channels.find((c) => c.id === id); + if (channel) { + actions.setChannelDisplayName(channel.display_name); + } else { + actions.setChannelDisplayName(''); + } + await actions.handleSelectChannel(id); EventEmitter.emit('close_channel_drawer'); InteractionManager.runAfterInteractions(() => { diff --git a/app/screens/more_dms/index.js b/app/screens/more_dms/index.js index 483d184c7..9a3a919f3 100644 --- a/app/screens/more_dms/index.js +++ b/app/screens/more_dms/index.js @@ -4,6 +4,7 @@ import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; +import {setChannelDisplayName} from 'app/actions/views/channel'; import {makeDirectChannel} from 'app/actions/views/more_dms'; import {getTheme} from 'app/selectors/preferences'; import {getProfiles, searchProfiles} from 'mattermost-redux/actions/users'; @@ -41,7 +42,8 @@ function mapDispatchToProps(dispatch) { actions: bindActionCreators({ makeDirectChannel, getProfiles, - searchProfiles + searchProfiles, + setChannelDisplayName }, dispatch) }; } diff --git a/app/screens/more_dms/more_dms.js b/app/screens/more_dms/more_dms.js index b154f820e..f654dadaa 100644 --- a/app/screens/more_dms/more_dms.js +++ b/app/screens/more_dms/more_dms.js @@ -12,7 +12,7 @@ import { import {General, RequestStatus} from 'mattermost-redux/constants'; import EventEmitter from 'mattermost-redux/utils/event_emitter'; -import {filterProfilesMatchingTerm} from 'mattermost-redux/utils/user_utils'; +import {displayUsername, filterProfilesMatchingTerm} from 'mattermost-redux/utils/user_utils'; import Loading from 'app/components/loading'; import MemberList from 'app/components/custom_list'; @@ -33,7 +33,8 @@ class MoreDirectMessages extends PureComponent { actions: PropTypes.shape({ makeDirectChannel: PropTypes.func.isRequired, getProfiles: PropTypes.func.isRequired, - searchProfiles: PropTypes.func.isRequired + searchProfiles: PropTypes.func.isRequired, + setChannelDisplayName: PropTypes.func.isRequired }).isRequired }; @@ -131,8 +132,17 @@ class MoreDirectMessages extends PureComponent { }; onSelectMember = async (id) => { + const {actions, preferences, profiles} = this.props; + const user = profiles.find((p) => p.id === id); + this.setState({adding: true}); - await this.props.actions.makeDirectChannel(id); + + if (user) { + actions.setChannelDisplayName(displayUsername(user, preferences)); + } else { + actions.setChannelDisplayName(''); + } + await actions.makeDirectChannel(id); EventEmitter.emit('close_channel_drawer'); InteractionManager.runAfterInteractions(() => {