From 2ecbc37071e17a6baf24f549c14fa4a37357ac3a Mon Sep 17 00:00:00 2001 From: Deimos Date: Wed, 12 Sep 2018 19:14:39 -0600 Subject: [PATCH] Skip viewer's comments when uncollapsing new ones --- tildes/tildes/models/comment/comment_tree.py | 6 +++++- tildes/tildes/views/topic.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tildes/tildes/models/comment/comment_tree.py b/tildes/tildes/models/comment/comment_tree.py index ae3e0a7..ddbfa21 100644 --- a/tildes/tildes/models/comment/comment_tree.py +++ b/tildes/tildes/models/comment/comment_tree.py @@ -174,7 +174,7 @@ class CommentTree: if comment.tag_counts["noise"] >= 2: 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.""" for comment in reversed(self.comments): # as soon as we reach an old comment, we can stop @@ -188,6 +188,10 @@ class CommentTree: if comment.collapsed_state: continue + # don't apply to the viewer's own comments + if comment.user == viewer: + continue + # uncollapse the comment comment.collapsed_state = "uncollapsed" diff --git a/tildes/tildes/views/topic.py b/tildes/tildes/views/topic.py index ef47b37..4ae6310 100644 --- a/tildes/tildes/views/topic.py +++ b/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 # (and doesn't have that behavior disabled) 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() return {