Browse Source

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.
merge-requests/37/head
Deimos 6 years ago
parent
commit
39380dcff6
  1. 13
      tildes/tildes/models/comment/comment_tree.py

13
tildes/tildes/models/comment/comment_tree.py

@ -198,11 +198,20 @@ class CommentTree:
def finalize_collapsing_maximized(self) -> None: def finalize_collapsing_maximized(self) -> None:
"""Finish collapsing comments, collapsing as much as possible.""" """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: for comment in self.tree:
comment.recursively_collapse() 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: for comment in self.tree:
comment.collapsed_state = None comment.collapsed_state = None

Loading…
Cancel
Save