diff options
Diffstat (limited to 'webapp/components/post.jsx')
-rw-r--r-- | webapp/components/post.jsx | 80 |
1 files changed, 26 insertions, 54 deletions
diff --git a/webapp/components/post.jsx b/webapp/components/post.jsx index ae3fa9c98..2b28d442c 100644 --- a/webapp/components/post.jsx +++ b/webapp/components/post.jsx @@ -4,14 +4,9 @@ import PostHeader from './post_header.jsx'; import PostBody from './post_body.jsx'; -import PostStore from 'stores/post_store.jsx'; -import ChannelStore from 'stores/channel_store.jsx'; - import Constants from 'utils/constants.jsx'; const ActionTypes = Constants.ActionTypes; -import Client from 'utils/web_client.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; import * as Utils from 'utils/utils.jsx'; import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; @@ -23,7 +18,6 @@ export default class Post extends React.Component { this.handleCommentClick = this.handleCommentClick.bind(this); this.forceUpdateInfo = this.forceUpdateInfo.bind(this); - this.retryPost = this.retryPost.bind(this); this.state = {}; } @@ -44,36 +38,6 @@ export default class Post extends React.Component { this.refs.info.forceUpdate(); this.refs.header.forceUpdate(); } - retryPost(e) { - e.preventDefault(); - - var post = this.props.post; - Client.createPost(post, - (data) => { - AsyncClient.getPosts(); - - 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 = Utils.getTimestamp(); - 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(); - } shouldComponentUpdate(nextProps) { if (!Utils.areObjectsEqual(nextProps.post, this.props.post)) { return true; @@ -103,6 +67,10 @@ export default class Post extends React.Component { return true; } + if (nextProps.compactDisplay !== this.props.compactDisplay) { + return true; + } + if (!Utils.areObjectsEqual(nextProps.user, this.props.user)) { return true; } @@ -187,24 +155,21 @@ export default class Post extends React.Component { systemMessageClass = 'post--system'; } - let profilePic = null; - if (!this.props.hideProfilePic) { + let profilePic = ( + <img + src={Utils.getProfilePicSrcForPost(post, timestamp)} + height='36' + width='36' + /> + ); + + if (Utils.isSystemMessage(post)) { profilePic = ( - <img - src={Utils.getProfilePicSrcForPost(post, timestamp)} - height='36' - width='36' + <span + className='icon' + dangerouslySetInnerHTML={{__html: mattermostLogo}} /> ); - - if (Utils.isSystemMessage(post)) { - profilePic = ( - <span - className='icon' - dangerouslySetInnerHTML={{__html: mattermostLogo}} - /> - ); - } } let centerClass = ''; @@ -212,11 +177,16 @@ export default class Post extends React.Component { centerClass = 'center'; } + let compactClass = ''; + if (this.props.compactDisplay) { + compactClass = 'post--compact'; + } + return ( <div> <div id={'post_' + post.id} - className={'post ' + sameUserClass + ' ' + rootUser + ' ' + postType + ' ' + currentUserCss + ' ' + shouldHighlightClass + ' ' + systemMessageClass} + className={'post ' + sameUserClass + ' ' + compactClass + ' ' + rootUser + ' ' + postType + ' ' + currentUserCss + ' ' + shouldHighlightClass + ' ' + systemMessageClass} > <div className={'post__content ' + centerClass}> <div className='post__img'>{profilePic}</div> @@ -231,6 +201,7 @@ export default class Post extends React.Component { sameUser={this.props.sameUser} user={this.props.user} currentUser={this.props.currentUser} + compactDisplay={this.props.compactDisplay} /> <PostBody post={post} @@ -238,7 +209,7 @@ export default class Post extends React.Component { parentPost={parentPost} posts={posts} handleCommentClick={this.handleCommentClick} - retryPost={this.retryPost} + compactDisplay={this.props.compactDisplay} /> </div> </div> @@ -261,5 +232,6 @@ Post.propTypes = { displayNameType: React.PropTypes.string, hasProfiles: React.PropTypes.bool, currentUser: React.PropTypes.object.isRequired, - center: React.PropTypes.bool + center: React.PropTypes.bool, + compactDisplay: React.PropTypes.bool }; |