Skip to content

Commit 5552f13

Browse files
committed
fix: increment parent comment ncomments
1 parent c1675e4 commit 5552f13

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

components/show-new-comments.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ function prepareComments (client, newComments) {
2323
return fragment
2424
}).filter(Boolean)
2525

26-
// count the total number of comments including nested comments
27-
let totalNComments = data.ncomments + freshNewComments.length
26+
// count the total number of new comments including its nested new comments
27+
let totalNComments = freshNewComments.length
2828
for (const comment of freshNewComments) {
2929
totalNComments += (comment.ncomments || 0)
3030
}
3131

3232
// update all ancestors
3333
const ancestors = data.path.split('.')
34-
updateAncestorsCommentCount(client, ancestors, totalNComments)
34+
updateAncestorsCommentCount(client.cache, ancestors, totalNComments)
3535

3636
return {
3737
...data,
3838
comments: { ...data.comments, comments: [...freshNewComments, ...data.comments.comments] },
39-
ncomments: totalNComments,
39+
ncomments: data.ncomments + totalNComments,
4040
newComments: []
4141
}
4242
}

0 commit comments

Comments
 (0)