Browse Source

Skip viewer's comments when uncollapsing new ones

merge-requests/37/head
Deimos 6 years ago
parent
commit
2ecbc37071
  1. 6
      tildes/tildes/models/comment/comment_tree.py
  2. 2
      tildes/tildes/views/topic.py

6
tildes/tildes/models/comment/comment_tree.py

@ -174,7 +174,7 @@ class CommentTree:
if comment.tag_counts["noise"] >= 2: if comment.tag_counts["noise"] >= 2:
comment.collapsed_state = "full" comment.collapsed_state = "full"
def uncollapse_new_comments(self, threshold: datetime) -> None:
def uncollapse_new_comments(self, viewer: User, threshold: datetime) -> None:
"""Mark comments newer than the threshold (and parents) to stay uncollapsed.""" """Mark comments newer than the threshold (and parents) to stay uncollapsed."""
for comment in reversed(self.comments): for comment in reversed(self.comments):
# as soon as we reach an old comment, we can stop # as soon as we reach an old comment, we can stop
@ -188,6 +188,10 @@ class CommentTree:
if comment.collapsed_state: if comment.collapsed_state:
continue continue
# don't apply to the viewer's own comments
if comment.user == viewer:
continue
# uncollapse the comment # uncollapse the comment
comment.collapsed_state = "uncollapsed" comment.collapsed_state = "uncollapsed"

2
tildes/tildes/views/topic.py

@ -289,7 +289,7 @@ def get_topic(request: Request, comment_order: CommentSortOption) -> dict:
# collapse old comments if the user has a previous visit to the topic # collapse old comments if the user has a previous visit to the topic
# (and doesn't have that behavior disabled) # (and doesn't have that behavior disabled)
if topic.last_visit_time and request.user.collapse_old_comments: if topic.last_visit_time and request.user.collapse_old_comments:
tree.uncollapse_new_comments(topic.last_visit_time)
tree.uncollapse_new_comments(request.user, topic.last_visit_time)
tree.finalize_collapsing_maximized() tree.finalize_collapsing_maximized()
return { return {

Loading…
Cancel
Save