minor improvement to notifs

master
Aevann 2023-03-11 10:51:19 +02:00
parent 19e3145f45
commit 69649cb503
2 changed files with 23 additions and 17 deletions

View File

@ -325,13 +325,10 @@ def notifications(v:User):
for c, n in comments: for c, n in comments:
c.notified_utc = n.created_utc c.notified_utc = n.created_utc
c.collapse = n.read
for c, n in comments: for c, n in comments:
if n.created_utc > 1620391248: c.notif_utc = n.created_utc if n.created_utc > 1620391248: c.notif_utc = n.created_utc
if not n.read and not session.get("GLOBAL"):
n.read = True
c.unread = True
g.db.add(n)
if c.parent_submission or c.wall_user_id: if c.parent_submission or c.wall_user_id:
total.append(c) total.append(c)
@ -349,6 +346,7 @@ def notifications(v:User):
if not hasattr(c, "notified_utc") or n.created_utc > c.notified_utc: if not hasattr(c, "notified_utc") or n.created_utc > c.notified_utc:
c.notified_utc = n.created_utc c.notified_utc = n.created_utc
c.collapse = n.read
c.replies2 = g.db.query(Comment).filter_by(parent_comment_id=c.id).filter(or_(Comment.author_id == v.id, Comment.id.in_(cids))).all() c.replies2 = g.db.query(Comment).filter_by(parent_comment_id=c.id).filter(or_(Comment.author_id == v.id, Comment.id.in_(cids))).all()
@ -366,6 +364,11 @@ def notifications(v:User):
if c not in listing: listing.append(c) if c not in listing: listing.append(c)
if not n.read and not session.get("GLOBAL"):
n.read = True
c.unread = True
g.db.add(n)
total.extend(listing) total.extend(listing)
listing2 = {} listing2 = {}

View File

@ -511,19 +511,22 @@
{% if render_replies %} {% if render_replies %}
<div id="replies-of-{{c.fullname}}"> <div id="replies-of-{{c.fullname}}">
{% if request.path.startswith('/notifications') and replies|length > 8 %} {% if request.path.startswith('/notifications') %}
{% for reply in replies %} {% if replies|length > 8 %}
{% if reply.parent_submission %} {% for reply in replies %}
{% set collapse = not reply.unread and not reply.replies(sort=sort, v=v) %} {% if reply.parent_submission %}
{% else %} {% set collapse = reply.collapse %}
{% set collapse = not reply.unread and loop.index != replies|length %} {% else %}
{% endif %} {% set collapse = not reply.unread and loop.index != replies|length %}
{{single_comment(reply, level=level+1, collapse=collapse)}} {% endif %}
{% endfor %}
{% elif request.path.startswith('/notifications') or level < 9 %} {{single_comment(reply, level=level+1, collapse=collapse)}}
{% for reply in replies %} {% endfor %}
{{single_comment(reply, level=level+1)}} {% elif level < 9 %}
{% endfor %} {% for reply in replies %}
{{single_comment(reply, level=level+1)}}
{% endfor %}
{% endif %}
{% elif replies %} {% elif replies %}
<button type="button" id="btn-{{c.id}}" class="d-mob-none btn btn-primary mt-3" data-nonce="{{g.nonce}}" data-onclick="more_comments('{{c.id}}', '{{sort}}')">More comments</button> <button type="button" id="btn-{{c.id}}" class="d-mob-none btn btn-primary mt-3" data-nonce="{{g.nonce}}" data-onclick="more_comments('{{c.id}}', '{{sort}}')">More comments</button>
<a class="d-md-none py-3" href="{{c.more_comments}}">More comments <i class="fas fa-long-arrow-right ml-1"></i></a> <a class="d-md-none py-3" href="{{c.more_comments}}">More comments <i class="fas fa-long-arrow-right ml-1"></i></a>