From b79669d313261126125d47fa063a92ce2ab80f87 Mon Sep 17 00:00:00 2001 From: MrOrz Date: Thu, 6 Jan 2022 00:27:16 +0800 Subject: [PATCH] [Reply] reply detail page should work for DELETED & BLOCKED content --- pages/reply/[id].js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/pages/reply/[id].js b/pages/reply/[id].js index 435baa6f..a88cd039 100644 --- a/pages/reply/[id].js +++ b/pages/reply/[id].js @@ -66,7 +66,7 @@ const LOAD_REPLY = gql` id text createdAt - articleReplies { + articleReplies(statuses: [NORMAL, DELETED]) { article { id text @@ -84,7 +84,7 @@ const LOAD_REPLY = gql` node { id text - articleReplies(status: NORMAL) { + articleReplies { articleId } } @@ -100,7 +100,7 @@ const LOAD_REPLY_FOR_USER = gql` query LoadReplyPageForUser($id: String!) { GetReply(id: $id) { id - articleReplies { + articleReplies(statuses: [NORMAL, DELETED]) { ...ArticleReplyForUser } } @@ -228,6 +228,29 @@ function ReplyPage() { articleReply.createdAt < earliest.createdAt ? articleReply : earliest, reply.articleReplies[0] ); + + // reply.articleReplies can be empty if all article replies are in BLOCKED state. + // Return a minimalist reply detail page that cannot be indexed by search engines. + // + if (!originalArticleReply) { + return ( + + + + {ellipsis(reply.text, { wordCount: 100 })} | {t`Cofacts`} + + + +
+ + {t`This reply`} + {reply.text} + +
+
+ ); + } + const isDeleted = originalArticleReply.status === 'DELETED'; const otherArticleReplies = reply.articleReplies