From 7ad2781eb53a100f9053e37588b2c098f7449725 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Sun, 7 Jan 2024 22:28:13 +1300 Subject: [PATCH] UI to let people change comment sort order --- app/post/routes.py | 6 ++++-- app/templates/post/post.html | 13 ++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/post/routes.py b/app/post/routes.py index 8ba7f3d3..b26ad467 100644 --- a/app/post/routes.py +++ b/app/post/routes.py @@ -29,8 +29,10 @@ def show_post(post_id: int): if community.banned: abort(404) + sort = request.args.get('sort', 'top') + # If nothing has changed since their last visit, return HTTP 304 - current_etag = f"{post.id}_{hash(post.last_active)}" + current_etag = f"{post.id}{sort}_{hash(post.last_active)}" if current_user.is_anonymous and request_etag_matches(current_etag): return return_304(current_etag) @@ -165,7 +167,7 @@ def show_post(post_id: int): return redirect(url_for('activitypub.post_ap', post_id=post_id)) # redirect to current page to avoid refresh resubmitting the form else: - replies = post_replies(post.id, 'top') + replies = post_replies(post.id, sort) form.notify_author.data = True og_image = post.image.source_url if post.image_id else None diff --git a/app/templates/post/post.html b/app/templates/post/post.html index 9810d7c7..4128708c 100644 --- a/app/templates/post/post.html +++ b/app/templates/post/post.html @@ -44,8 +44,19 @@

{{ _('Comments are disabled.') }}

{% endif %} {% if replies %} -
+
+ {% macro render_comment(comment) %}