Skip to content

Commit b861468

Browse files
author
Vikas Agarwal
committed
Github issue#585, Ignore 'user-joined' type posts in Topic comments
-- Ignored empty posts whose author are 'system'
1 parent fb3b049 commit b861468

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/projects/detail/containers/FeedContainer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,18 @@ class FeedView extends React.Component {
103103
author: isSystemUser(p.userId) ? SYSTEM_USER : allMembers[p.userId]
104104
}
105105
}
106+
const validPost = (post) => {
107+
return post.type === 'post' && (post.body && post.body.trim().length || !isSystemUser(post.userId))
108+
}
106109
if (showAll) {
107110
// if we are showing all comments, just iterate through the entire array
108111
_.forEach(_.slice(feed.posts, 1), p => {
109-
p.type === 'post' ? item.comments.push(_toComment(p)) : item.totalComments--
112+
validPost(p) ? item.comments.push(_toComment(p)) : item.totalComments--
110113
})
111114
} else {
112115
// otherwise iterate from right and add to the beginning of the array
113116
_.forEachRight(_.slice(feed.posts, 1), (p) => {
114-
p.type === 'post' ? item.comments.unshift(_toComment(p)) : item.totalComments--
117+
validPost(p) ? item.comments.unshift(_toComment(p)) : item.totalComments--
115118
if (!feed.showAll && item.comments.length === THREAD_MESSAGES_PAGE_SIZE)
116119
return false
117120
})

src/projects/detail/containers/MessagesContainer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,18 @@ class MessagesView extends React.Component {
113113
author: isSystemUser(p.userId) ? SYSTEM_USER : allMembers[p.userId]
114114
}
115115
}
116+
const validPost = (post) => {
117+
return post.type === 'post' && (post.body && post.body.trim().length || !isSystemUser(post.userId))
118+
}
116119
if (showAll) {
117120
// if we are showing all comments, just iterate through the entire array
118121
_.forEach(feed.posts, p => {
119-
p.type === 'post' ? item.messages.push(_toComment(p)) : item.totalComments--
122+
validPost(p) ? item.messages.push(_toComment(p)) : item.totalComments--
120123
})
121124
} else {
122125
// otherwise iterate from right and add to the beginning of the array
123126
_.forEachRight(feed.posts, (p) => {
124-
p.type === 'post' ? item.messages.unshift(_toComment(p)) : item.totalComments--
127+
validPost(p) ? item.messages.unshift(_toComment(p)) : item.totalComments--
125128
if (!feed.showAll && item.messages.length === THREAD_MESSAGES_PAGE_SIZE)
126129
return false
127130
})

0 commit comments

Comments
 (0)