From 39380dcff6d304d7ef1ff5d15ed2d7533a073967 Mon Sep 17 00:00:00 2001 From: Deimos Date: Wed, 12 Sep 2018 17:13:38 -0600 Subject: [PATCH] Fix interaction between tag/old comment collapsing One of the weird behaviors so far with comment collapsing was that if a top-level comment was collapsed due to being tagged as "noise", and then all other top-level comments were also collapsed due to being made up entirely of old comments, the end result would be all comments being uncollapsed, including the "noise" one. This probably still isn't a proper fix for it, but should be better. The whole system of interactions between different collapsing processes probably needs re-thinking or this is going to get very confusing as more "reasons for collapsing" come in. --- tildes/tildes/models/comment/comment_tree.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tildes/tildes/models/comment/comment_tree.py b/tildes/tildes/models/comment/comment_tree.py index 011c925..ae3e0a7 100644 --- a/tildes/tildes/models/comment/comment_tree.py +++ b/tildes/tildes/models/comment/comment_tree.py @@ -198,11 +198,20 @@ class CommentTree: def finalize_collapsing_maximized(self) -> None: """Finish collapsing comments, collapsing as much as possible.""" + # whether the collapsed state of all top-level comments starts out unknown + all_top_unknown_initially = all( + [comment.collapsed_state is None for comment in self.tree] + ) + for comment in self.tree: comment.recursively_collapse() - # if all the top-level comments end up fully collapsed, uncollapse instead - if all([comment.collapsed_state == "full" for comment in self.tree]): + # if all the top-level comments were initially uncertain but end up + # fully collapsed, uncollapse them all instead (so we don't have a + # comment page that's all collapsed comments) + if all_top_unknown_initially and all( + [comment.collapsed_state == "full" for comment in self.tree] + ): for comment in self.tree: comment.collapsed_state = None