From fd96b5c5e36e96d497de36bca459b1e840dd4621 Mon Sep 17 00:00:00 2001 From: enahum Date: Mon, 19 Jun 2017 09:10:59 -0400 Subject: [PATCH] Fix DM title when open from user profile (#634) --- app/screens/user_profile/index.js | 6 +++++- app/screens/user_profile/user_profile.js | 17 ++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/screens/user_profile/index.js b/app/screens/user_profile/index.js index d79502e0b..fc68fd798 100644 --- a/app/screens/user_profile/index.js +++ b/app/screens/user_profile/index.js @@ -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) }; } diff --git a/app/screens/user_profile/user_profile.js b/app/screens/user_profile/user_profile.js index 0db76093f..dd1348e80 100644 --- a/app/screens/user_profile/user_profile.js +++ b/app/screens/user_profile/user_profile.js @@ -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 {displayName}; @@ -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 { { flex: 1, backgroundColor: theme.centerChannelBg }, - scrollViewContent: { - flex: 1 - }, text: { fontSize: 15, color: theme.centerChannelColor