never collapse when #context is in the url (so page jumping to highlighted comment actually works) (sometimes the highlighted comment would be a child of a collapsed comment which prevents jumping)

pull/180/head
Aevann 2023-08-05 13:08:19 +03:00
parent 2c78ab6593
commit 5f968f0006
2 changed files with 3 additions and 3 deletions

View File

@ -381,12 +381,12 @@ class Comment(Base):
return body
@lazy
def collapse_for_user(self, v, path=''):
def collapse_for_user(self, v, comment_info, path=''):
if v and self.author_id == v.id: return False
if path == '/admin/removed/comments': return False
if path.endswith(f'/{self.id}'): return False
if comment_info: return False
if self.over_18 and not (v and v.over_18) and not (any(path.startswith(x) for x in ('/post/','/comment/','/h/')) and self.post.over_18): return True

View File

@ -113,7 +113,7 @@
{% set isreply = False %}
{% endif %}
<div id="comment-{{c.id}}" class="anchor comment {% if wall and level == 1 %}mt-5{% elif wall %}mt-4{% elif standalone and level==1 %}mt-0{% endif %} {% if collapse or c.collapse_for_user(v,request.full_path) %}collapsed{% endif %}" style="{% if isreply %}padding-left:0!important{% endif %}">
<div id="comment-{{c.id}}" class="anchor comment {% if wall and level == 1 %}mt-5{% elif wall %}mt-4{% elif standalone and level==1 %}mt-0{% endif %} {% if collapse or c.collapse_for_user(v, comment_info, request.full_path) %}collapsed{% endif %}" style="{% if isreply %}padding-left:0!important{% endif %}">
{% if not isreply %}
<span class="comment-collapse-desktop" style="border-color: {% if c.ghost %}var(--primary){% else %}#{{c.author.name_color}}{% endif %}" data-nonce="{{g.nonce}}" data-onclick="collapse_comment('{{c.id}}')"></span>
{% endif %}