Update channel header whit mode dms and more channels (#664)

This commit is contained in:
enahum 2017-06-23 16:12:11 -04:00 committed by Harrison Healey
parent 2a7c487463
commit d057e3c1ab
5 changed files with 35 additions and 14 deletions

View file

@ -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 = (
<TouchableOpacity
onPress={this.showFileAttachmentOptions}

View file

@ -11,7 +11,7 @@ import {getCurrentUserRoles} from 'mattermost-redux/selectors/entities/users';
import {showCreateOption} from 'mattermost-redux/utils/channel_utils';
import {isAdmin, isSystemAdmin} from 'mattermost-redux/utils/user_utils';
import {handleSelectChannel} from 'app/actions/views/channel';
import {handleSelectChannel, setChannelDisplayName} from 'app/actions/views/channel';
import {getTheme} from 'app/selectors/preferences';
import MoreChannels from './more_channels';
@ -41,7 +41,8 @@ function mapDispatchToProps(dispatch) {
handleSelectChannel,
joinChannel,
getChannels,
searchChannels
searchChannels,
setChannelDisplayName
}, dispatch)
};
}

View file

@ -36,7 +36,8 @@ class MoreChannels extends PureComponent {
handleSelectChannel: PropTypes.func.isRequired,
joinChannel: PropTypes.func.isRequired,
getChannels: PropTypes.func.isRequired,
searchChannels: PropTypes.func.isRequired
searchChannels: PropTypes.func.isRequired,
setChannelDisplayName: PropTypes.func.isRequired
}).isRequired
};
@ -201,13 +202,20 @@ class MoreChannels extends PureComponent {
};
onSelectChannel = async (id) => {
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(() => {

View file

@ -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)
};
}

View file

@ -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(() => {