Fix DM title when open from user profile (#634)

This commit is contained in:
enahum 2017-06-19 09:10:59 -04:00 committed by GitHub
parent 2693ffc18b
commit fd96b5c5e3
2 changed files with 13 additions and 10 deletions

View file

@ -4,9 +4,11 @@
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {setChannelDisplayName} from 'app/actions/views/channel';
import {handleSendMessage} from 'app/actions/views/user_profile';
import {getTheme} from 'app/selectors/preferences';
import {getMyPreferences} from 'mattermost-redux/selectors/entities/preferences';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import UserProfile from './user_profile';
@ -19,6 +21,7 @@ function mapStateToProps(state, ownProps) {
config,
currentUserId: getCurrentUserId(state),
user: state.entities.users.profiles[ownProps.userId],
myPreferences: getMyPreferences(state),
theme: getTheme(state)
};
}
@ -26,7 +29,8 @@ function mapStateToProps(state, ownProps) {
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
handleSendMessage
handleSendMessage,
setChannelDisplayName
}, dispatch)
};
}

View file

@ -13,27 +13,29 @@ import {
import ProfilePicture from 'app/components/profile_picture';
import StatusBar from 'app/components/status_bar';
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
import {getFullName} from 'mattermost-redux/utils/user_utils';
import {displayUsername} from 'mattermost-redux/utils/user_utils';
import UserProfileRow from './user_profile_row';
export default class UserProfile extends PureComponent {
static propTypes = {
actions: PropTypes.shape({
handleSendMessage: PropTypes.func.isRequired
handleSendMessage: PropTypes.func.isRequired,
setChannelDisplayName: PropTypes.func.isRequired
}).isRequired,
config: PropTypes.object.isRequired,
currentUserId: PropTypes.string.isRequired,
navigator: PropTypes.object,
myPreferences: PropTypes.object,
theme: PropTypes.object.isRequired,
user: PropTypes.object.isRequired
};
getDisplayName = () => {
const {theme, user} = this.props;
const {theme, myPreferences, user} = this.props;
const style = createStyleSheet(theme);
const displayName = getFullName(user);
const displayName = displayUsername(user, myPreferences);
if (displayName) {
return <Text style={style.displayName}>{displayName}</Text>;
@ -59,7 +61,8 @@ export default class UserProfile extends PureComponent {
};
sendMessage = () => {
const {actions, navigator, user} = this.props;
const {actions, myPreferences, navigator, user} = this.props;
actions.setChannelDisplayName(displayUsername(user, myPreferences));
actions.handleSendMessage(user.id);
navigator.pop({
animated: true
@ -75,7 +78,6 @@ export default class UserProfile extends PureComponent {
<StatusBar/>
<ScrollView
style={style.scrollView}
contentContainerStyle={style.scrollViewContent}
>
<View style={style.top}>
<ProfilePicture
@ -134,9 +136,6 @@ const createStyleSheet = makeStyleSheetFromTheme((theme) => {
flex: 1,
backgroundColor: theme.centerChannelBg
},
scrollViewContent: {
flex: 1
},
text: {
fontSize: 15,
color: theme.centerChannelColor