Skip to content

Commit

Permalink
feat(article): don't show reply requests with <=0 score for users not…
Browse files Browse the repository at this point in the history
… logged in yet
  • Loading branch information
MrOrz committed Jan 24, 2023
1 parent ade621b commit 2dc5431
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pages/article/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit 2dc5431

Please sign in to comment.