Browse Source

Don't stop recursively collapsing at uncollapsed

merge-requests/37/head
Deimos 6 years ago
parent
commit
05def39afa
  1. 11
      tildes/tildes/models/comment/comment_tree.py

11
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()
Loading…
Cancel
Save