From ecac519efb8c5071d39ea0dff2e3c045c0a3789e Mon Sep 17 00:00:00 2001 From: soxa <6390896+Soxasora@users.noreply.github.com> Date: Thu, 24 Jul 2025 06:47:53 +0200 Subject: [PATCH] Fix clear new comments on route change (#2319) --- components/comment.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/components/comment.js b/components/comment.js index d90687ff..6dab627e 100644 --- a/components/comment.js +++ b/components/comment.js @@ -309,6 +309,7 @@ export function ViewAllReplies ({ id, nshown, nhas }) { function ReplyOnAnotherPage ({ item }) { const root = useRoot() const rootId = commentSubTreeRootId(item, root) + const { cache } = useApolloClient() let text = 'reply on another page' if (item.ncomments > 0) { @@ -316,7 +317,24 @@ function ReplyOnAnotherPage ({ item }) { } return ( - + { + // clear new comments going to another page + cache.writeFragment({ + id: `Item:${item.id}`, + fragment: gql` + fragment NewComments on Item { + newComments + }`, + data: { + newComments: [] + } + }) + }} + href={`/items/${rootId}?commentId=${item.id}`} + as={`/items/${rootId}`} + className='pb-2 fw-bold d-flex align-items-center gap-2 text-muted' + > {text} {item.newComments?.length > 0 &&
}