Fix crashes when user hasn't loaded and when postDraft was undefined

This commit is contained in:
Elias Nahum 2017-10-05 16:39:17 -03:00 committed by enahum
parent 77fdaa9058
commit e082b42947
4 changed files with 7 additions and 9 deletions

View file

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

View file

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

View file

@ -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';
@ -14,7 +13,6 @@ 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,
@ -22,7 +20,7 @@ function mapStateToProps(state, ownProps) {
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)
};
}

View file

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