Browse Source

Exclude removed comments from "last comment" link

The "last comment posted" link in the sidebar on a topic's comments page
was still considering removed comments, so if the last comment in a
topic was removed it would link to that one. That's not very useful for
anyone, so this excludes removed comments the same way that deleted ones
were already excluded.
merge-requests/126/merge
Deimos 4 years ago
parent
commit
624123929a
  1. 4
      tildes/tildes/models/comment/comment_tree.py
  2. 2
      tildes/tildes/templates/topic.jinja2

4
tildes/tildes/models/comment/comment_tree.py

@ -181,9 +181,9 @@ class CommentTree:
@property
def most_recent_comment(self) -> Optional[Comment]:
"""Return the most recent non-deleted Comment in the tree."""
"""Return the most recent Comment in the tree (excluding deleted/removed)."""
for comment in reversed(self.comments):
if not comment.is_deleted:
if not (comment.is_deleted or comment.is_removed):
return comment
return None

2
tildes/tildes/templates/topic.jinja2

@ -326,7 +326,7 @@
<dt>Last comment posted</dt>
<dd>
<a href="{{ comments.most_recent_comment.permalink }}" data-js-hide-sidebar-no-preventdefault>
{{ adaptive_date_responsive(topic.last_activity_time) }}
{{ adaptive_date_responsive(comments.most_recent_comment.created_time) }}
</a>
</dd>
{% else %}

Loading…
Cancel
Save