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 @@
Change the default sorting for comments.