Spirit icon indicating copy to clipboard operation
Spirit copied to clipboard

Unread comments count and number of comments don't match

Open nitely opened this issue 9 years ago • 9 comments

Basically, topic's actions (topic pinned, etc) are not being counted as comments and that is ok, but... actions are actually comments and that creates some issues.

The unread comments count (the red highlighting when there's a new comment) feature relies on the bookmark and the comment count, it does something like (comments_count - bookmark.comment_number) to calculate if there is a new comment. When there is an action posted, the bookmark.comment_number will be greater than comments_count, so the next new comment won't be counted as unread.

There are three ways of fixing this thing: 1. add a post_count field to track all kind of posts (comments and actions) and calculate the unread count (something like actions_count won't quite work: see https://github.com/nitely/Spirit/issues/131) or 2. make the unread comments count an app (ie: extra join to a OneToOne table) or 3. decouple actions from comments somehow (still requires a post_count field to handle deleted comments).

:+1: to option 1.

Reported by @alesdotio here.

nitely avatar Sep 30 '16 21:09 nitely

OK, I'll go with option 1 coz it's required regardless (ie: to handle deleted comments count).

But I think decoupling actions from comments would be really cool, so they don't count as page items. Also, styling them ala github would be great!

nitely avatar Oct 01 '16 16:10 nitely

Will deleted comments not count towards the comment count any more? If so, could we also add an option to not show them in the topic at all?

alesdotio avatar Oct 01 '16 16:10 alesdotio

Will deleted comments not count towards the comment count any more?

Not sure, but probably.

If so, could we also add an option to not show them in the topic at all?

Nop. That would break notifications and the bookmarking.

nitely avatar Oct 01 '16 16:10 nitely

Just checked, the bookmark can be updated to comment_number - 1. The notifications are trickier, if the there is a mention then it's broken anyway (it takes the user to a deleted comment), if it's a new comment then it can be updated to the next comment.

So it can be done. It adds a bunch of complexity though. IMHO, the only upside of doing this is so deleted comments are not page items, but other than that I don't see why it would be a good idea.

nitely avatar Oct 01 '16 17:10 nitely

We could just skip them whle rendering, maybe that's what you meant. That can be done.

nitely avatar Oct 01 '16 17:10 nitely

That'w what I do but then the count and pagination is off.

alesdotio avatar Oct 01 '16 17:10 alesdotio

I meant literally skip them while rendering (ie: {% if comment.is_removed %}). The problem is if all comments are deleted in a given page then that page will be empty, or if there are too many deleted comments, it may look weird.

If you filter them out in the database query, that will break many things.

nitely avatar Oct 01 '16 17:10 nitely

Yeah, it works ok-ish with just hiding them.

Anyway, any chance of fixing the count issue?

alesdotio avatar Oct 18 '16 19:10 alesdotio

Yes, I will try to get it done this soon.

nitely avatar Nov 05 '16 19:11 nitely