From b861468e3591615eb5b22b9361892bbc78c443eb Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Thu, 15 Dec 2016 14:49:10 +0530 Subject: [PATCH] Github issue#585, Ignore 'user-joined' type posts in Topic comments -- Ignored empty posts whose author are 'system' --- src/projects/detail/containers/FeedContainer.js | 7 +++++-- src/projects/detail/containers/MessagesContainer.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/projects/detail/containers/FeedContainer.js b/src/projects/detail/containers/FeedContainer.js index 4a36eb3bb..f621ca219 100644 --- a/src/projects/detail/containers/FeedContainer.js +++ b/src/projects/detail/containers/FeedContainer.js @@ -103,15 +103,18 @@ class FeedView extends React.Component { author: isSystemUser(p.userId) ? SYSTEM_USER : allMembers[p.userId] } } + const validPost = (post) => { + return post.type === 'post' && (post.body && post.body.trim().length || !isSystemUser(post.userId)) + } if (showAll) { // if we are showing all comments, just iterate through the entire array _.forEach(_.slice(feed.posts, 1), p => { - p.type === 'post' ? item.comments.push(_toComment(p)) : item.totalComments-- + validPost(p) ? item.comments.push(_toComment(p)) : item.totalComments-- }) } else { // otherwise iterate from right and add to the beginning of the array _.forEachRight(_.slice(feed.posts, 1), (p) => { - p.type === 'post' ? item.comments.unshift(_toComment(p)) : item.totalComments-- + validPost(p) ? item.comments.unshift(_toComment(p)) : item.totalComments-- if (!feed.showAll && item.comments.length === THREAD_MESSAGES_PAGE_SIZE) return false }) diff --git a/src/projects/detail/containers/MessagesContainer.js b/src/projects/detail/containers/MessagesContainer.js index 2bc1f1ae9..6b3455a84 100644 --- a/src/projects/detail/containers/MessagesContainer.js +++ b/src/projects/detail/containers/MessagesContainer.js @@ -113,15 +113,18 @@ class MessagesView extends React.Component { author: isSystemUser(p.userId) ? SYSTEM_USER : allMembers[p.userId] } } + const validPost = (post) => { + return post.type === 'post' && (post.body && post.body.trim().length || !isSystemUser(post.userId)) + } if (showAll) { // if we are showing all comments, just iterate through the entire array _.forEach(feed.posts, p => { - p.type === 'post' ? item.messages.push(_toComment(p)) : item.totalComments-- + validPost(p) ? item.messages.push(_toComment(p)) : item.totalComments-- }) } else { // otherwise iterate from right and add to the beginning of the array _.forEachRight(feed.posts, (p) => { - p.type === 'post' ? item.messages.unshift(_toComment(p)) : item.totalComments-- + validPost(p) ? item.messages.unshift(_toComment(p)) : item.totalComments-- if (!feed.showAll && item.messages.length === THREAD_MESSAGES_PAGE_SIZE) return false })