// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import PostStore from '../stores/post_store.jsx'; import ChannelStore from '../stores/channel_store.jsx'; import UserProfile from './user_profile.jsx'; import UserStore from '../stores/user_store.jsx'; import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; import * as Utils from '../utils/utils.jsx'; import Constants from '../utils/constants.jsx'; import FileAttachmentList from './file_attachment_list.jsx'; import * as Client from '../utils/client.jsx'; import * as AsyncClient from '../utils/async_client.jsx'; var ActionTypes = Constants.ActionTypes; import * as TextFormatting from '../utils/text_formatting.jsx'; import twemoji from 'twemoji'; import * as EventHelpers from '../dispatcher/event_helpers.jsx'; import {intlShape, injectIntl, defineMessages, FormattedMessage, FormattedDate} from 'mm-intl'; const holders = defineMessages({ comment: { id: 'rhs_comment.comment', defaultMessage: 'Comment' } }); class RhsComment extends React.Component { constructor(props) { super(props); this.retryComment = this.retryComment.bind(this); this.parseEmojis = this.parseEmojis.bind(this); this.state = {}; } retryComment(e) { e.preventDefault(); var post = this.props.post; Client.createPost(post, post.channel_id, (data) => { AsyncClient.getPosts(post.channel_id); var channel = ChannelStore.get(post.channel_id); var member = ChannelStore.getMember(post.channel_id); member.msg_count = channel.total_msg_count; member.last_viewed_at = (new Date()).getTime(); ChannelStore.setChannelMember(member); AppDispatcher.handleServerAction({ type: ActionTypes.RECEIVED_POST, post: data }); }, () => { post.state = Constants.POST_FAILED; PostStore.updatePendingPost(post); this.forceUpdate(); } ); post.state = Constants.POST_LOADING; PostStore.updatePendingPost(post); this.forceUpdate(); } parseEmojis() { twemoji.parse(ReactDOM.findDOMNode(this), {size: Constants.EMOJI_SIZE}); } componentDidMount() { this.parseEmojis(); } shouldComponentUpdate(nextProps) { if (!Utils.areObjectsEqual(nextProps.post, this.props.post)) { return true; } return false; } componentDidUpdate() { this.parseEmojis(); } createDropdown() { var post = this.props.post; if (post.state === Constants.POST_FAILED || post.state === Constants.POST_LOADING || post.state === Constants.POST_DELETED) { return ''; } var isOwner = UserStore.getCurrentId() === post.user_id; var isAdmin = Utils.isAdmin(UserStore.getCurrentUser().roles); var dropdownContents = []; if (isOwner) { dropdownContents.push(