Bug & Suggestions: comment count can be wrong
botbotty opened this issue · comments
botbotty commented
How to reproduce:
- make a page with the following code:
<p>blah blah blah</p>
<span data-cusdis-count-page-id="cusdis-test/">0</span> comments
<script defer data-host="https://cusdis.com"
data-app-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
src="https://cusdis.com/js/cusdis-count.umd.js"></script>
<div id="cusdis_thread"
data-host="https://cusdis.com"
data-app-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
data-page-id="cusdis-test/"
data-page-url="https://example.com/cusdis-test/"
data-page-title="cusdis test"
></div>
<script async defer src="https://cusdis.com/js/cusdis.es.js"></script>
- Refresh the page, it shows "0 comments";
- Send a comment, then refresh the page, it shows "1 comments";
- Goto the cusdis dashboard, reply to the comment in step 3 (but not click approve);
- Refresh the page, it shows "2 comments";
- Goto the cusdis dashboard, delete the comment in step 3 without deleting the reply in step 4;
- Refresh the page.
Expected behavior
The page shows "0 comments".
Actual behavior
The page shows "1 comments".
Other questions
- In the new comment notification email, when I "append reply as moderator", it automatically approve the comment. But if I reply to a pending comment in the dashboard, the comment will not be approved automatically. Could you make the two methods behave the same?
- It seems that the comment count shows the number of both approved and pending comments/replies. Do you think it makes more sense to let it just show "visible" comments? That is, if a comment is pending, but a reply to it has been made and approved, they count as zero "visible" comment. When the root comment is approved, then they should count as two. Further more, how do you like the idea to show the number of comments and replies separately (like "xxx comments, and yyy replies")?
- One suggestion: merge the comment count function into the "main" script (https://cusdis.com/js/cusdis.es.js). Users can use for example 'data-show-count="1"/"0"' to switch the function on/off. This will save the time fetching another script. Also, you can use the i18n to translate the "xxx comments" string and handle singular and plural properly.
- Another suggestion: merge the i18n script into the "main" script. You could let the server to prepare the script with sepcified language when receiving a request for "js/cusdis-zh-cn.es.js" or for "js/cusdis-fr.es.js" so you don't have to actually duplicate the script. In this way, users don't have to fetch three scripts just in order to have both comment count and i18n.
LilMP commented
Have similar problem here.
- Initiate a page. It shows "0 comments";
- Leave a comment, approved in the dashboard, then refresh the page, it shows "1 comments";
- Go to the dashboard, reply to the comment and also approved; Refresh the page, it shows "2 comments";
- Go to the dashboard, delete the original comment, both comments(original and reply) are disappeared.
- Refresh the page. But the counter shows "1 comment."
Expected behavior
The page should show "0 comments".
(Since deleting the parent thread will also delete the children comments, the latter should not be counted in the counter.)