Skip to content

Commit

Permalink
add back collapsed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
guoliu committed Feb 19, 2020
1 parent efe7d29 commit b274eb4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/common/utils/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ interface Comment {
}

export const filterComment = (comment: Comment) => {
const isActive = comment.state === 'active'
// skip if comment's state is active or collapse
if (comment.state === 'active' || comment.state === 'collapsed') {
return true
}

const isDescendant = comment.parentComment && comment.parentComment.id
const descendants = _get(comment, 'comments.edges', [])
const hasActiveDescendants =
descendants.filter(({ node }: { node: Comment }) => node.state === 'active')
.length > 0

// skip if comment's state is active
if (isActive) {
return true
}
descendants.filter(
({ node }: { node: Comment }) =>
node.state === 'active' || node.state === 'collapsed'
).length > 0

// filter out if it's a decendant comment
if (isDescendant) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ const ResponseComment = ({
)}
</ul>
)}

<style jsx>{styles}</style>
</section>
)
Expand Down

0 comments on commit b274eb4

Please sign in to comment.