From b2ef7fa795377cdb2f4cfb50a58a365a619b3f68 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 4 Sep 2017 15:51:04 +0700 Subject: [PATCH] Fix tombstone bug --- .../src/components/AllCommentsPane.js | 11 +++----- .../src/components/Comment.js | 28 ++++++++++++------- .../src/components/Stream.js | 11 -------- .../src/containers/Comment.js | 5 ++++ 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/client/coral-embed-stream/src/components/AllCommentsPane.js b/client/coral-embed-stream/src/components/AllCommentsPane.js index 1617b8c4f..7602902df 100644 --- a/client/coral-embed-stream/src/components/AllCommentsPane.js +++ b/client/coral-embed-stream/src/components/AllCommentsPane.js @@ -1,7 +1,6 @@ import React from 'react'; import LoadMore from './LoadMore'; -import IgnoredCommentTombstone from './IgnoredCommentTombstone'; import NewCount from './NewCount'; import {TransitionGroup} from 'react-transition-group'; import {forEachError} from 'coral-framework/utils'; @@ -138,7 +137,6 @@ class AllCommentsPane extends React.Component { loadNewReplies, deleteAction, showSignInDialog, - commentIsIgnored, charCountEnable, maxCharCount, editComment, @@ -156,9 +154,8 @@ class AllCommentsPane extends React.Component { /> {view.map((comment) => { - return commentIsIgnored(comment) - ? - : ; + /> + ); })} u.id === comment.user.id) + ); + } + hasIgnoredReplies() { return this.props.comment.replies && - this.props.comment.replies.nodes.some((reply) => this.props.commentIsIgnored(reply)); + this.props.comment.replies.nodes.some((reply) => this.commentIsIgnored(reply)); } loadNewReplies = () => { @@ -327,12 +333,15 @@ export default class Comment extends React.Component { charCountEnable, showSignInDialog, liveUpdates, - commentIsIgnored, animateEnter, emit, commentClassNames = [] } = this.props; + if (this.commentIsIgnored(comment)) { + return ; + } + const view = this.getVisibileReplies(); // Inactive comments can be viewed by moderators and admins (e.g. using permalinks). @@ -566,9 +575,8 @@ export default class Comment extends React.Component { {view.map((reply) => { - return commentIsIgnored(reply) - ? - : ; + /> + ); })}
diff --git a/client/coral-embed-stream/src/components/Stream.js b/client/coral-embed-stream/src/components/Stream.js index 575c1fd00..89e7b13ae 100644 --- a/client/coral-embed-stream/src/components/Stream.js +++ b/client/coral-embed-stream/src/components/Stream.js @@ -40,15 +40,6 @@ class Stream extends React.Component { } } - commentIsIgnored = (comment) => { - const me = this.props.root.me; - return ( - me && - me.ignoredUsers && - me.ignoredUsers.find((u) => u.id === comment.user.id) - ); - }; - renderHighlightedComment() { const { data, @@ -104,7 +95,6 @@ class Stream extends React.Component { deleteAction={deleteAction} showSignInDialog={showSignInDialog} key={topLevelComment.id} - commentIsIgnored={this.commentIsIgnored} comment={topLevelComment} charCountEnable={asset.settings.charCountEnable} maxCharCount={asset.settings.charCount} @@ -193,7 +183,6 @@ class Stream extends React.Component { loadNewReplies={loadNewReplies} deleteAction={deleteAction} showSignInDialog={showSignInDialog} - commentIsIgnored={this.commentIsIgnored} charCountEnable={asset.settings.charCountEnable} maxCharCount={asset.settings.charCount} editComment={editComment} diff --git a/client/coral-embed-stream/src/containers/Comment.js b/client/coral-embed-stream/src/containers/Comment.js index a4bfbc0eb..f24dc8b01 100644 --- a/client/coral-embed-stream/src/containers/Comment.js +++ b/client/coral-embed-stream/src/containers/Comment.js @@ -93,6 +93,11 @@ const withCommentFragments = withFragments({ fragment CoralEmbedStream_Comment_root on RootQuery { __typename ${getSlotFragmentSpreads(slots, 'root')} + me { + ignoredUsers { + id + } + } } `, asset: gql`