From 2dc543117ac9804ee906d5351c11d1bc178b5abf Mon Sep 17 00:00:00 2001 From: MrOrz Date: Tue, 24 Jan 2023 20:11:07 +0800 Subject: [PATCH] feat(article): don't show reply requests with <=0 score for users not logged in yet --- pages/article/[id].js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pages/article/[id].js b/pages/article/[id].js index d16456e5..742aae24 100644 --- a/pages/article/[id].js +++ b/pages/article/[id].js @@ -199,6 +199,8 @@ const LOAD_ARTICLE_FOR_USER = gql` id # Required, https://github.com/apollographql/apollo-client/issues/2510 originalAttachmentUrl: attachmentUrl(variant: ORIGINAL) replyRequests(statuses: $replyRequestStatuses) { + positiveFeedbackCount + negativeFeedbackCount ...ReplyRequestInfoForUser } articleReplies(statuses: $articleReplyStatuses) { @@ -345,7 +347,11 @@ function ArticlePage() { ); const replyRequestsWithComments = (article.replyRequests || []).filter( - ({ reason }) => reason + ({ reason, positiveFeedbackCount, negativeFeedbackCount }) => + reason && + reason.trim().length > 0 && + // For users not logged in yet, only show reply requests with positive feedbacks + (currentUser ? true : positiveFeedbackCount - negativeFeedbackCount > 0) ); return (