diff --git a/files/routes/front.py b/files/routes/front.py index e83349e189..91fbc264fb 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -43,6 +43,8 @@ def notifications(v): comments.append(c) g.db.bulk_update_mappings(Notification, notifs) + g.db.commit() + next_exists = (len(comments) > 25) listing = comments[:25] else: @@ -58,15 +60,18 @@ def notifications(v): cids = [x.comment_id for x in notifications] comments = get_comments(cids, v=v, load_parent=True) + notifs = [] i = 0 for x in notifications: try: if not x.read: comments[i].unread = True except: continue - x.read = True - g.db.add(x) + notifs.append({'id': x.id, 'read': True}) i += 1 + g.db.bulk_update_mappings(Notification, notifs) + g.db.commit() + if not posts: listing = [] for c in comments: @@ -96,8 +101,6 @@ def notifications(v): listing.append(c) - g.db.commit() - return render_template("notifications.html", v=v, notifications=listing,