diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 417d8ae88..cbce73e71 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -438,6 +438,7 @@ POST_SORTS = COMMENT_SORTS | { "subscriptions": "bell", "saves": "save" } +COMMENT_SORTS = COMMENT_SORTS | {"saves": "save"} ################################################################################ ### COLUMN INFO diff --git a/files/helpers/sorting_and_time.py b/files/helpers/sorting_and_time.py index 431661a4c..d45b39335 100644 --- a/files/helpers/sorting_and_time.py +++ b/files/helpers/sorting_and_time.py @@ -47,6 +47,8 @@ def sort_objects(sort, objects, cls): return objects.outerjoin(Subscription, Subscription.post_id == cls.id).group_by(cls.id).order_by(func.count(Subscription.post_id).desc(), cls.created_utc.desc()) elif sort == "saves" and cls.__name__ == "Post": return objects.outerjoin(SaveRelationship, SaveRelationship.post_id == cls.id).group_by(cls.id).order_by(func.count(SaveRelationship.post_id).desc(), cls.created_utc.desc()) + elif sort == "saves" and cls.__name__ == "Comment": + return objects.outerjoin(CommentSaveRelationship, CommentSaveRelationship.comment_id == cls.id).group_by(cls.id).order_by(func.count(CommentSaveRelationship.comment_id).desc(), cls.created_utc.desc()) elif sort == "new": return objects.order_by(cls.created_utc.desc()) elif sort == "old": diff --git a/files/templates/home.html b/files/templates/home.html index 2706069e5..05a9f354c 100644 --- a/files/templates/home.html +++ b/files/templates/home.html @@ -86,7 +86,7 @@ {{- macros.time_filter_buttons() -}} - {{- macros.sorting_buttons(POST_SORTS, True) -}} + {{- macros.sorting_buttons(POST_SORTS, True, True) -}} {% endblock %} diff --git a/files/templates/home_comments.html b/files/templates/home_comments.html index c06dfc846..c4da5eea3 100644 --- a/files/templates/home_comments.html +++ b/files/templates/home_comments.html @@ -8,7 +8,7 @@
{{- macros.time_filter_buttons() -}} - {{- macros.sorting_buttons(COMMENT_SORTS) -}} + {{- macros.sorting_buttons(COMMENT_SORTS, True) -}}
diff --git a/files/templates/post.html b/files/templates/post.html index 4faafc745..eeacb0ce3 100644 --- a/files/templates/post.html +++ b/files/templates/post.html @@ -330,7 +330,7 @@
- {{- macros.sorting_buttons(COMMENT_SORTS, True) -}} + {{- macros.sorting_buttons(COMMENT_SORTS, False, True) -}}
{{macros.comment_reply_box(p.fullname, 'comment-reply-' + p.fullname, subwrapper_css_classes='mb-3', enable_cancel_button=false)}} diff --git a/files/templates/post_banned.html b/files/templates/post_banned.html index 24372aa55..d9fae08ba 100644 --- a/files/templates/post_banned.html +++ b/files/templates/post_banned.html @@ -49,7 +49,7 @@
- {{- macros.sorting_buttons(COMMENT_SORTS, True) -}} + {{- macros.sorting_buttons(COMMENT_SORTS, False, True) -}}
diff --git a/files/templates/search.html b/files/templates/search.html index 642e90f5a..697491ff1 100644 --- a/files/templates/search.html +++ b/files/templates/search.html @@ -105,9 +105,9 @@
{{- macros.time_filter_buttons() -}} {% if "/posts" in request.path %} - {{- macros.sorting_buttons(POST_SORTS) -}} + {{- macros.sorting_buttons(POST_SORTS, True) -}} {% else %} - {{- macros.sorting_buttons(COMMENT_SORTS) -}} + {{- macros.sorting_buttons(COMMENT_SORTS, True) -}} {% endif %}
{% endif %} diff --git a/files/templates/settings/advanced.html b/files/templates/settings/advanced.html index 5b24686de..1dd257b0e 100644 --- a/files/templates/settings/advanced.html +++ b/files/templates/settings/advanced.html @@ -66,7 +66,7 @@

Change the default sorting for comments.

diff --git a/files/templates/userpage/header.html b/files/templates/userpage/header.html index 7288b3ede..e72ff641d 100644 --- a/files/templates/userpage/header.html +++ b/files/templates/userpage/header.html @@ -32,9 +32,9 @@
{{- macros.time_filter_buttons() -}} {% if "/posts" in request.path %} - {{- macros.sorting_buttons(POST_SORTS) -}} + {{- macros.sorting_buttons(POST_SORTS, True) -}} {% else %} - {{- macros.sorting_buttons(COMMENT_SORTS) -}} + {{- macros.sorting_buttons(COMMENT_SORTS, True) -}} {% endif %}
diff --git a/files/templates/util/macros.html b/files/templates/util/macros.html index 4bd37d5ae..d8a29d3c0 100644 --- a/files/templates/util/macros.html +++ b/files/templates/util/macros.html @@ -400,7 +400,7 @@
{% endmacro %} -{% macro sorting_buttons(sorts, hot_allowed) %} +{% macro sorting_buttons(sorts, saves_allowed, hot_allowed) %}