From 69649cb503b8a647944b69f3062a9d1624dd82eb Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 11 Mar 2023 10:51:19 +0200 Subject: [PATCH] minor improvement to notifs --- files/routes/notifications.py | 11 +++++++---- files/templates/comments.html | 29 ++++++++++++++++------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/files/routes/notifications.py b/files/routes/notifications.py index 51919218a..92f4c3a26 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -325,13 +325,10 @@ def notifications(v:User): for c, n in comments: c.notified_utc = n.created_utc + c.collapse = n.read for c, n in comments: 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: total.append(c) @@ -349,6 +346,7 @@ def notifications(v:User): if not hasattr(c, "notified_utc") or n.created_utc > c.notified_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() @@ -366,6 +364,11 @@ def notifications(v:User): 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) listing2 = {} diff --git a/files/templates/comments.html b/files/templates/comments.html index 9fde2205c..237f90ce3 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -511,19 +511,22 @@ {% if render_replies %}
- {% if request.path.startswith('/notifications') and replies|length > 8 %} - {% for reply in replies %} - {% if reply.parent_submission %} - {% set collapse = not reply.unread and not reply.replies(sort=sort, v=v) %} - {% else %} - {% set collapse = not reply.unread and loop.index != replies|length %} - {% endif %} - {{single_comment(reply, level=level+1, collapse=collapse)}} - {% endfor %} - {% elif request.path.startswith('/notifications') or level < 9 %} - {% for reply in replies %} - {{single_comment(reply, level=level+1)}} - {% endfor %} + {% if request.path.startswith('/notifications') %} + {% if replies|length > 8 %} + {% for reply in replies %} + {% if reply.parent_submission %} + {% set collapse = reply.collapse %} + {% else %} + {% set collapse = not reply.unread and loop.index != replies|length %} + {% endif %} + + {{single_comment(reply, level=level+1, collapse=collapse)}} + {% endfor %} + {% elif level < 9 %} + {% for reply in replies %} + {{single_comment(reply, level=level+1)}} + {% endfor %} + {% endif %} {% elif replies %} More comments