From 05def39afad868eb4ab91d7dc366019678c22fb2 Mon Sep 17 00:00:00 2001 From: Deimos Date: Thu, 13 Sep 2018 01:20:18 -0600 Subject: [PATCH] Don't stop recursively collapsing at uncollapsed --- tildes/tildes/models/comment/comment_tree.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tildes/tildes/models/comment/comment_tree.py b/tildes/tildes/models/comment/comment_tree.py index 86d0808..3c5a79a 100644 --- a/tildes/tildes/models/comment/comment_tree.py +++ b/tildes/tildes/models/comment/comment_tree.py @@ -252,8 +252,8 @@ class CommentInTree(ObjectProxy): def recursively_collapse(self) -> None: """Recursively collapse a comment and its replies as much as possible.""" - # stop processing this branch if we hit an uncollapsed/fully-collapsed comment - if self.collapsed_state in ("uncollapsed", "full"): + # stop processing this branch if we hit a fully-collapsed comment + if self.collapsed_state == "full": return # if it doesn't have any uncollapsed descendants, collapse the whole branch @@ -263,7 +263,10 @@ class CommentInTree(ObjectProxy): return # otherwise (does have uncollapsed descendant), collapse this comment - # individually and recurse into all branches underneath it - self.collapsed_state = "individual" + # individually if it doesn't already have another state set, then recurse into + # all branches underneath it + if not self.collapsed_state: + self.collapsed_state = "individual" + for reply in self.replies: reply.recursively_collapse()