Skip to content

Commit

Permalink
Fix crashes when user hasn't loaded and when postDraft was undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
enahum committed Oct 5, 2017
1 parent 77fdaa9 commit e082b42
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/components/autocomplete/at_mention/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function mapStateToProps(state, ownProps) {
const {cursorPosition, isSearch, rootId} = ownProps;
const currentChannelId = getCurrentChannelId(state);

let postDraft;
let postDraft = '';
if (isSearch) {
postDraft = state.views.search;
} else if (ownProps.rootId) {
Expand Down
2 changes: 1 addition & 1 deletion app/components/autocomplete/channel_mention/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function mapStateToProps(state, ownProps) {
const {cursorPosition, isSearch, rootId} = ownProps;
const currentChannelId = getCurrentChannelId(state);

let postDraft;
let postDraft = '';
if (isSearch) {
postDraft = state.views.search;
} else if (rootId) {
Expand Down
4 changes: 1 addition & 3 deletions app/components/post_profile_picture/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import {connect} from 'react-redux';

import {getPost} from 'mattermost-redux/selectors/entities/posts';
import {getUser} from 'mattermost-redux/selectors/entities/users';
import {isSystemMessage} from 'mattermost-redux/utils/post_utils';

import {getTheme} from 'app/selectors/preferences';
Expand All @@ -14,15 +13,14 @@ import PostProfilePicture from './post_profile_picture';
function mapStateToProps(state, ownProps) {
const {config} = state.entities.general;
const post = getPost(state, ownProps.postId);
const user = getUser(state, post.user_id);

return {
...ownProps,
enablePostIconOverride: config.EnablePostIconOverride === 'true',
fromWebHook: post.props && post.props.from_webhook === 'true',
isSystemMessage: isSystemMessage(post),
overrideIconUrl: post.props && post.props.override_icon_url,
user,
userId: post.user_id,
theme: getTheme(state)
};
}
Expand Down
8 changes: 4 additions & 4 deletions app/components/post_profile_picture/post_profile_picture.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function PostProfilePicture(props) {
onViewUserProfile,
overrideIconUrl,
theme,
user
userId
} = props;
if (isSystemMessage) {
return (
Expand Down Expand Up @@ -51,7 +51,7 @@ function PostProfilePicture(props) {

return (
<ProfilePicture
userId={user.id}
userId={userId}
size={PROFILE_PICTURE_SIZE}
/>
);
Expand All @@ -60,7 +60,7 @@ function PostProfilePicture(props) {
return (
<TouchableOpacity onPress={onViewUserProfile}>
<ProfilePicture
userId={user.id}
userId={userId}
size={PROFILE_PICTURE_SIZE}
/>
</TouchableOpacity>
Expand All @@ -74,7 +74,7 @@ PostProfilePicture.propTypes = {
overrideIconUrl: PropTypes.string,
onViewUserProfile: PropTypes.func,
theme: PropTypes.object,
user: PropTypes.object
userId: PropTypes.string
};

PostProfilePicture.defaultProps = {
Expand Down

0 comments on commit e082b42

Please sign in to comment.