remotes/1693045480750635534/spooky-22
Aevann1 2021-09-01 17:51:27 +02:00
parent 4fd28db30c
commit 2023bfc7fc
3 changed files with 27 additions and 53 deletions

View File

@ -365,50 +365,6 @@ class User(Base, Stndrd, Age_times):
secondrange = firstrange + 26
return comments[firstrange:secondrange]
def notification_subscriptions(self, page=1):
notifications = self.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT)
notifications = notifications.options(
contains_eager(Notification.comment)
)
notifications = notifications.order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26)
output = []
for x in notifications:
x.read = True
g.db.add(x)
output.append(x.comment_id)
return output
def notification_commentlisting(self, page=1):
notifications = self.notifications.join(Notification.comment).filter(
Comment.is_banned == False,
Comment.deleted_utc == 0,
Comment.author_id != AUTOJANNY_ACCOUNT,
)
if not all_:
notifications = notifications.filter(Notification.read == False)
notifications = notifications.options(
contains_eager(Notification.comment)
)
notifications = notifications.order_by(
Notification.id.desc()).offset(25 * (page - 1)).limit(26)
output = []
for x in notifications:
x.read = True
g.db.add(x)
output.append(x.comment_id)
return output
@property
@lazy
def notifications_count(self):

View File

@ -26,15 +26,33 @@ def notifications(v):
cids = cids[:25]
comments = get_comments(cids, v=v)
elif posts:
cids = v.notification_subscriptions(page=page)
next_exists = (len(cids) == 26)
cids = cids[:25]
comments = get_comments(cids, v=v)
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26)
comments = []
for x in notifications:
c = x.comment
if not x.read: c.unread = True
x.read = True
g.db.add(x)
comments.append(c)
next_exists = (len(comments) == 26)
comments = comments[:25]
else:
cids = v.notification_commentlisting(page=page)
next_exists = (len(cids) == 26)
cids = cids[:25]
comments = get_comments(cids, v=v, load_parent=True)
notifications = v.notifications.join(Notification.comment).filter(
Comment.is_banned == False,
Comment.deleted_utc == 0,
Comment.author_id != AUTOJANNY_ACCOUNT,
).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26)
comments = []
for x in notifications:
c = x.comment
if not x.read: c.unread = True
x.read = True
g.db.add(x)
comments.append(c)
next_exists = (len(comments) == 26)
comments = comments[:25]
listing = []
for c in comments:

View File

@ -105,7 +105,7 @@
</div>
{% endif %}
<div id="comment-{{c.id}}" class="comment {% if standalone and level==1 %} mt-0{% endif %}{% if c.collapse_for_user(v) or (standalone and c.over_18 and not (v and v.over_18)) %} collapsed{% endif %}" style="border-left: 2px solid #{{c.author.namecolor}};">
<div id="comment-{{c.id}}" class="comment {% if standalone and level==1 %} mt-0{% endif %}{% if c.collapse_for_user(v) or (standalone and c.over_18 and not (v and v.over_18)) %} collapsed{% endif %}" style="border-left: 2px solid #{{c.author.namecolor}};{% if c.unread %}padding: 10px; border: 2px solid $primary;{% endif %}">
<span class="comment-collapse-desktop d-none d-md-block" style="border-left: 2px solid #{{c.author.namecolor}};" onclick="collapse_comment('{{c.id}}')"></span>