From 38e263d931ff14db4581b0d50aeb987e4684718a Mon Sep 17 00:00:00 2001 From: Michael House Date: Sat, 10 Sep 2022 08:57:29 -0500 Subject: [PATCH] Added filter to make sure new comments only show up on page refresh --- files/routes/posts.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index fb5fcf5fc..01580fe0f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -283,6 +283,8 @@ def viewmore(v, pid, sort, offset): try: ids = set(int(x) for x in request.values.get("ids").split(',')) except: abort(400) + newest = g.db.query(Comment).filter(Comment.id.in_(ids)).order_by(Comment.created_utc.desc()).first() + if v: votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery() @@ -328,7 +330,7 @@ def viewmore(v, pid, sort, offset): comment.is_blocked = c[3] or 0 output.append(comment) - comments = comments.filter(Comment.level == 1) + comments = comments.filter(Comment.level == 1).filter(Comment.created_utc < newest.created_utc) if sort == "new": comments = comments.order_by(Comment.created_utc.desc()) @@ -356,7 +358,7 @@ def viewmore(v, pid, sort, offset): elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) - comments = comments.all() + comments = comments.filter(Comment.created_utc < newest.created_utc).all() comments = comments[offset:] limit = app.config['RESULTS_PER_PAGE_COMMENTS']