Skip to content

Commit

Permalink
Merge pull request #469 from cofacts/fix-reply-detail
Browse files Browse the repository at this point in the history
[Reply] reply detail page should work for DELETED & BLOCKED content
  • Loading branch information
MrOrz authored Jan 6, 2022
2 parents 46a813b + b79669d commit d10987d
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions pages/reply/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const LOAD_REPLY = gql`
id
text
createdAt
articleReplies {
articleReplies(statuses: [NORMAL, DELETED]) {
article {
id
text
Expand All @@ -84,7 +84,7 @@ const LOAD_REPLY = gql`
node {
id
text
articleReplies(status: NORMAL) {
articleReplies {
articleId
}
}
Expand All @@ -100,7 +100,7 @@ const LOAD_REPLY_FOR_USER = gql`
query LoadReplyPageForUser($id: String!) {
GetReply(id: $id) {
id
articleReplies {
articleReplies(statuses: [NORMAL, DELETED]) {
...ArticleReplyForUser
}
}
Expand Down Expand Up @@ -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 (
<AppLayout>
<Head>
<title>
{ellipsis(reply.text, { wordCount: 100 })} | {t`Cofacts`}
</title>
<meta name="robots" content="noindex" />
</Head>
<div className={classes.root}>
<Card>
<CardHeader>{t`This reply`}</CardHeader>
<CardContent>{reply.text}</CardContent>
</Card>
</div>
</AppLayout>
);
}

const isDeleted = originalArticleReply.status === 'DELETED';

const otherArticleReplies = reply.articleReplies
Expand Down

0 comments on commit d10987d

Please sign in to comment.