* Fixed copyright date * Removed unnecessary components folder from channel scene * Added initial version of post textbox * Moved getTheme into a proper selector * Moved ChannelHeader into its own component * Flipped post list so that the most recent posts appear at the bottom * Moved post textbox value into redux view store * Switched new components from PureRenderMixin to React.PureComponent
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
import {connect} from 'react-redux';
|
|
|
|
import {Constants} from 'service/constants';
|
|
import {getMyPreferences, getTheme} from 'service/selectors/entities/preferences';
|
|
import {getCurrentUserId, getUser} from 'service/selectors/entities/users';
|
|
import {getUserIdFromChannelName} from 'service/utils/channel_utils';
|
|
import {displayUsername} from 'service/utils/user_utils';
|
|
|
|
import ChannelHeader from './channel_header';
|
|
|
|
function mapStateToProps(state, ownProps) {
|
|
const currentChannel = ownProps.currentChannel;
|
|
|
|
let displayName = '';
|
|
if (currentChannel) {
|
|
if (currentChannel.type === Constants.DM_CHANNEL) {
|
|
const otherUser = getUser(state, getUserIdFromChannelName(getCurrentUserId(state), currentChannel));
|
|
|
|
if (otherUser) {
|
|
displayName = displayUsername(otherUser, getMyPreferences(state));
|
|
}
|
|
} else {
|
|
displayName = currentChannel.display_name;
|
|
}
|
|
}
|
|
|
|
return {
|
|
...ownProps,
|
|
displayName,
|
|
theme: getTheme(state)
|
|
};
|
|
}
|
|
|
|
export default connect(mapStateToProps)(ChannelHeader);
|