From afdcdff51e058524aa8ed728cdbda323eddc320d Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 6 Jun 2017 23:18:37 +0700 Subject: [PATCH] Handle ignored user case --- client/coral-embed-stream/src/components/Comment.js | 11 +++++++++-- client/coral-embed-stream/src/components/LoadMore.js | 3 +++ client/coral-embed-stream/src/containers/Stream.js | 2 +- client/coral-embed-stream/src/graphql/utils.js | 3 --- locales/en.yml | 1 + locales/es.yml | 1 + 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/client/coral-embed-stream/src/components/Comment.js b/client/coral-embed-stream/src/components/Comment.js index 177ac457d..730c2ca4a 100644 --- a/client/coral-embed-stream/src/components/Comment.js +++ b/client/coral-embed-stream/src/components/Comment.js @@ -204,6 +204,11 @@ class Comment extends React.Component { } } + hasIgnoredReplies() { + return this.props.comment.replies && + this.props.comment.replies.nodes.some((reply) => this.props.commentIsIgnored(reply)); + } + loadNewReplies = () => { const {replies, replyCount, id} = this.props.comment; if (replyCount > replies.nodes.length) { @@ -292,6 +297,8 @@ class Comment extends React.Component { } = this.props; const view = this.getVisibileReplies(); + const hasMoreComments = comment.replies && (comment.replies.hasNextPage || comment.replies.nodes.length > view.length); + const replyCount = this.hasIgnoredReplies() ? '' : comment.replyCount; const flagSummary = getActionSummary('FlagActionSummary', comment); const dontAgreeSummary = getActionSummary( 'DontAgreeActionSummary', @@ -524,8 +531,8 @@ class Comment extends React.Component {
view.length} + replyCount={replyCount} + moreComments={hasMoreComments} loadMore={this.loadNewReplies} />
diff --git a/client/coral-embed-stream/src/components/LoadMore.js b/client/coral-embed-stream/src/components/LoadMore.js index 31001fcd2..ca2816d10 100644 --- a/client/coral-embed-stream/src/components/LoadMore.js +++ b/client/coral-embed-stream/src/components/LoadMore.js @@ -9,6 +9,9 @@ class LoadMore extends React.Component { } replyCountFormat = (count) => { + if (!count) { + return t('framework.view_all_replies_unknown_number'); + } if (count === 1) { return t('framework.view_reply'); } diff --git a/client/coral-embed-stream/src/containers/Stream.js b/client/coral-embed-stream/src/containers/Stream.js index 360ee2ef9..6b4ae71ed 100644 --- a/client/coral-embed-stream/src/containers/Stream.js +++ b/client/coral-embed-stream/src/containers/Stream.js @@ -159,7 +159,7 @@ const commentFragment = gql` id ...${getDefinitionName(Comment.fragments.comment)} replyCount(excludeIgnored: $excludeIgnored) - replies { + replies(excludeIgnored: $excludeIgnored) { nodes { id ...${getDefinitionName(Comment.fragments.comment)} diff --git a/client/coral-embed-stream/src/graphql/utils.js b/client/coral-embed-stream/src/graphql/utils.js index d2a557f23..eff1e2439 100644 --- a/client/coral-embed-stream/src/graphql/utils.js +++ b/client/coral-embed-stream/src/graphql/utils.js @@ -177,8 +177,5 @@ function findAndInsertFetchedComments(parent, comments, parent_id) { } export function insertFetchedCommentsIntoEmbedQuery(root, comments, parent_id) { - if (!comments.nodes.length) { - return root; - } return applyToCommentsOrigin(root, (origin) => findAndInsertFetchedComments(origin, comments, parent_id)); } diff --git a/locales/en.yml b/locales/en.yml index 03fad3bc5..3f3b7fc0d 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -224,6 +224,7 @@ en: success_bio_update: "Your biography has been updated" success_name_update: "Your username has been updated" success_update_settings: "The changes you have made have been applied to the comment stream on this article" + view_all_replies_unknown_number: "view all replies" view_all_replies: "view {0} replies" view_all_replies_initial: "view all {0} replies" view_more_comments: "view more comments" diff --git a/locales/es.yml b/locales/es.yml index 9e7a8bcba..0802a7604 100644 --- a/locales/es.yml +++ b/locales/es.yml @@ -223,6 +223,7 @@ es: success_bio_update: "Tu biografia fue actualizada" success_name_update: "Tu nombre de usuario ha sido actualizado" success_update_settings: "La configuración de este articulo fue actualizada" + view_all_replies_unknown_number: "ver todas las respuestas" view_all_replies: "ver {0} respuestas" view_all_replies_initial: "ver todas las {0} respuestas" view_more_comments: "Ver más comentarios"