// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import UserStore from 'stores/user_store.jsx';
import * as Utils from 'utils/utils.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import * as PostUtils from 'utils/post_utils.jsx';
import Constants from 'utils/constants.jsx';
import CommentedOnFilesMessageContainer from './commented_on_files_message_container.jsx';
import FileAttachmentListContainer from 'components/file_attachment_list_container.jsx';
import PostBodyAdditionalContent from './post_body_additional_content.jsx';
import PostMessageContainer from './post_message_container.jsx';
import PendingPostOptions from './pending_post_options.jsx';
import ReactionListContainer from './reaction_list_container.jsx';
import {FormattedMessage} from 'react-intl';
import loadingGif from 'images/load.gif';
import React from 'react';
export default class PostBody extends React.Component {
constructor(props) {
super(props);
this.removePost = this.removePost.bind(this);
}
shouldComponentUpdate(nextProps) {
if (nextProps.isCommentMention !== this.props.isCommentMention) {
return true;
}
if (!Utils.areObjectsEqual(nextProps.post, this.props.post)) {
return true;
}
if (!Utils.areObjectsEqual(nextProps.parentPost, this.props.parentPost)) {
return true;
}
if (nextProps.compactDisplay !== this.props.compactDisplay) {
return true;
}
if (nextProps.previewCollapsed !== this.props.previewCollapsed) {
return true;
}
if (nextProps.handleCommentClick.toString() !== this.props.handleCommentClick.toString()) {
return true;
}
return false;
}
removePost() {
GlobalActions.emitRemovePost(this.props.post);
}
render() {
const post = this.props.post;
const parentPost = this.props.parentPost;
let comment = '';
let postClass = '';
if (parentPost) {
const profile = UserStore.getProfile(parentPost.user_id);
let apostrophe = '';
let name = '...';
if (profile != null) {
let username = profile.username;
if (parentPost.props &&
parentPost.props.from_webhook &&
parentPost.props.override_username &&
global.window.mm_config.EnablePostUsernameOverride === 'true') {
username = parentPost.props.override_username;
}
if (username.slice(-1) === 's') {
apostrophe = '\'';
} else {
apostrophe = '\'s';
}
name = (
{username}
);
}
let message = '';
if (parentPost.message) {
message = Utils.replaceHtmlEntities(parentPost.message);
} else if (parentPost.file_ids && parentPost.file_ids.length > 0) {
message = (