summaryrefslogtreecommitdiffstats
path: root/web/react/components/post.jsx
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-09-23 12:55:58 -0700
committer=Corey Hulen <corey@hulen.com>2015-09-23 12:55:58 -0700
commit2b5b8f95ed9de37a15dc68c38c46a1da2bb1e160 (patch)
treed5bf8318dc82d96cd34b83481e1cc5c8289d170a /web/react/components/post.jsx
parent9e04909c0a3672d27c148c931d82b225cc86dfe5 (diff)
parent0170cfe604e6cfb430be0b6181243ca85a9ab27b (diff)
downloadchat-2b5b8f95ed9de37a15dc68c38c46a1da2bb1e160.tar.gz
chat-2b5b8f95ed9de37a15dc68c38c46a1da2bb1e160.tar.bz2
chat-2b5b8f95ed9de37a15dc68c38c46a1da2bb1e160.zip
Merge branch 'master' into PLT-11-email
Diffstat (limited to 'web/react/components/post.jsx')
-rw-r--r--web/react/components/post.jsx51
1 files changed, 36 insertions, 15 deletions
diff --git a/web/react/components/post.jsx b/web/react/components/post.jsx
index d3c6befd0..9127f00de 100644
--- a/web/react/components/post.jsx
+++ b/web/react/components/post.jsx
@@ -51,7 +51,7 @@ export default class Post extends React.Component {
var post = this.props.post;
client.createPost(post, post.channel_id,
- function success(data) {
+ (data) => {
AsyncClient.getPosts();
var channel = ChannelStore.get(post.channel_id);
@@ -65,11 +65,11 @@ export default class Post extends React.Component {
post: data
});
},
- function error() {
+ () => {
post.state = Constants.POST_FAILED;
PostStore.updatePendingPost(post);
this.forceUpdate();
- }.bind(this)
+ }
);
post.state = Constants.POST_LOADING;
@@ -81,31 +81,52 @@ export default class Post extends React.Component {
return true;
}
- return false;
- }
- render() {
- var post = this.props.post;
- var parentPost = this.props.parentPost;
- var posts = this.props.posts;
+ if (nextProps.sameRoot !== this.props.sameRoot) {
+ return true;
+ }
- var type = 'Post';
- if (post.root_id && post.root_id.length > 0) {
- type = 'Comment';
+ if (nextProps.sameUser !== this.props.sameUser) {
+ return true;
+ }
+
+ if (this.getCommentCount(nextProps) !== this.getCommentCount(this.props)) {
+ return true;
}
- var commentCount = 0;
- var commentRootId;
+ return false;
+ }
+ getCommentCount(props) {
+ const post = props.post;
+ const parentPost = props.parentPost;
+ const posts = props.posts;
+
+ let commentCount = 0;
+ let commentRootId;
if (parentPost) {
commentRootId = post.root_id;
} else {
commentRootId = post.id;
}
- for (var postId in posts) {
+ for (let postId in posts) {
if (posts[postId].root_id === commentRootId) {
commentCount += 1;
}
}
+ return commentCount;
+ }
+ render() {
+ var post = this.props.post;
+ var parentPost = this.props.parentPost;
+ var posts = this.props.posts;
+
+ var type = 'Post';
+ if (post.root_id && post.root_id.length > 0) {
+ type = 'Comment';
+ }
+
+ const commentCount = this.getCommentCount(this.props);
+
var rootUser;
if (this.props.sameRoot) {
rootUser = 'same--root';