From f7a5f56955ce420bc2424995cd865c49d140d1b4 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sun, 22 Jul 2018 22:25:28 +0200 Subject: [PATCH] Fix the index --- app.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index 7f226d5..9d6d127 100644 --- a/app.py +++ b/app.py @@ -805,17 +805,23 @@ def index(): "meta.undo": False, "$or": [{"meta.pinned": False}, {"meta.pinned": {"$exists": False}}], } - q_pinned = { - "box": Box.OUTBOX.value, - "type": ActivityType.CREATE.value, - "meta.deleted": False, - "meta.undo": False, - "meta.pinned": True, - } - pinned = list(DB.activities.find(q_pinned)) + + pinned = [] + # Only fetch the pinned notes if we're on the first page + if not request.args.get("older_than") and not request.args.get("newer_than"): + q_pinned = { + "box": Box.OUTBOX.value, + "type": ActivityType.CREATE.value, + "meta.deleted": False, + "meta.undo": False, + "meta.pinned": True, + } + pinned = list(DB.activities.find(q_pinned)) + outbox_data, older_than, newer_than = paginated_query( DB.activities, q, limit=25 - len(pinned) ) + return render_template( "index.html", outbox_data=outbox_data,