Revert "add new pagination to notifs"

This reverts commit b80e42f156.
pull/146/head
Aevann 2023-05-05 02:08:56 +03:00
parent bcb663a72f
commit 49ce8617f2
2 changed files with 24 additions and 7 deletions

View File

@ -1,7 +1,6 @@
import time
from sqlalchemy.sql.expression import not_, and_, or_
from sqlalchemy.orm import load_only, defer
from files.classes.mod_logs import ModAction
from files.classes.sub_logs import SubAction
@ -299,12 +298,12 @@ def notifications(v:User):
Comment.is_banned != False,
Comment.deleted_utc != 0,
)
).options(defer('*')).all()
).all()
for n in unread_and_inaccessible:
n.read = True
g.db.add(n)
comments = g.db.query(Comment, Notification).options(load_only(Comment.id)).join(Notification.comment).filter(
comments = g.db.query(Comment, Notification).join(Notification.comment).filter(
Notification.user_id == v.id,
or_(Comment.sentto == None, Comment.sentto != v.id),
)
@ -321,9 +320,10 @@ def notifications(v:User):
)
comments = comments.order_by(Notification.created_utc.desc(), Comment.id.desc())
next_exists = comments.count()
comments = comments.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
comments = comments.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE+1).all()
next_exists = (len(comments) > PAGE_SIZE)
comments = comments[:PAGE_SIZE]
cids = [x[0].id for x in comments]
listing = []
@ -413,5 +413,4 @@ def notifications(v:User):
page=page,
standalone=True,
render_replies=True,
size=PAGE_SIZE,
)

View File

@ -131,7 +131,25 @@
{% block pagenav %}
{% if notifications %}
{% include "pagination.html" %}
<nav>
<ul class="pagination pagination-sm mb-0 mt-4">
{% if page>1 %}
<li class="page-item">
<small><a class="page-link" href="{{request.path}}?page={{page-1}}">Previous</a></small>
</li>
{% else %}
<li class="page-item disabled"><span class="page-link">Prev</span></li>
{% endif %}
{% if next_exists %}
<li class="page-item">
<small><a class="page-link" href="{{request.path}}?page={{page+1}}">Next</a></small>
</li>
{% else %}
<li class="page-item disabled"><span class="page-link">Next</span></li>
{% endif %}
</ul>
</nav>
{% endif %}
<link rel="stylesheet" href="{{('css/notifications.css') | asset}}">