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