From f71cbc33be20aa598164c0abc108cbf2eed14ae5 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Fri, 22 Jul 2022 12:29:11 -0700 Subject: [PATCH] Count replies in comment count --- demo/soudan.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/demo/soudan.js b/demo/soudan.js index f047c83..de8dbab 100644 --- a/demo/soudan.js +++ b/demo/soudan.js @@ -57,7 +57,13 @@ function reloadComments(jump) { }); }) .then(comments => { - commentContainerHeader.innerHTML = `${comments.length} Comment${comments.length == 1 ? "" : "s"}`; + let commentCount = comments.length; + comments.forEach(comment => { + if (comment.replies) { + commentCount += comment.replies.length; + } + }); + commentContainerHeader.innerHTML = `${commentCount} Comment${commentCount == 1 ? "" : "s"}`; let html = ""; if (comments.length == 0) { html = "

No comments yet! Be the first to make one.

";