diff --git a/app/models.py b/app/models.py index b6f1226c..38561343 100644 --- a/app/models.py +++ b/app/models.py @@ -617,6 +617,8 @@ class User(UserMixin, db.Model): markdown_editor = db.Column(db.Boolean, default=False) interface_language = db.Column(db.String(10)) # a locale that the translation system understands e.g. 'en' or 'en-us'. If empty, use browser default language_id = db.Column(db.Integer, db.ForeignKey('language.id')) # the default choice in the language dropdown when composing posts & comments + reply_collapse_threshold = db.Column(db.Integer, default=-10) + reply_hide_threshold = db.Column(db.Integer, default=-20) avatar = db.relationship('File', lazy='joined', foreign_keys=[avatar_id], single_parent=True, cascade="all, delete-orphan") cover = db.relationship('File', lazy='joined', foreign_keys=[cover_id], single_parent=True, cascade="all, delete-orphan") diff --git a/app/post/routes.py b/app/post/routes.py index e6cc1db8..2088016c 100644 --- a/app/post/routes.py +++ b/app/post/routes.py @@ -276,11 +276,13 @@ def show_post(post_id: int): recently_downvoted = recently_downvoted_posts(current_user.id) recently_upvoted_replies = recently_upvoted_post_replies(current_user.id) recently_downvoted_replies = recently_downvoted_post_replies(current_user.id) + reply_collapse_threshold = current_user.reply_collapse_threshold else: recently_upvoted = [] recently_downvoted = [] recently_upvoted_replies = [] recently_downvoted_replies = [] + reply_collapse_threshold = -10 # Polls poll_form = False @@ -316,6 +318,7 @@ def show_post(post_id: int): noindex=not post.author.indexable, preconnect=post.url if post.url else None, recently_upvoted=recently_upvoted, recently_downvoted=recently_downvoted, recently_upvoted_replies=recently_upvoted_replies, recently_downvoted_replies=recently_downvoted_replies, + reply_collapse_threshold=reply_collapse_threshold, etag=f"{post.id}{sort}_{hash(post.last_active)}", markdown_editor=current_user.is_authenticated and current_user.markdown_editor, low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1', SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER, SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR, diff --git a/app/post/util.py b/app/post/util.py index 7aa3d9c5..8ab4ca9f 100644 --- a/app/post/util.py +++ b/app/post/util.py @@ -21,6 +21,11 @@ def post_replies(post_id: int, sort_by: str, show_first: int = 0) -> List[PostRe blocked_accounts = blocked_users(current_user.id) if blocked_accounts: comments = comments.filter(PostReply.user_id.not_in(blocked_accounts)) + if current_user.reply_hide_threshold: + comments = comments.filter(PostReply.score > current_user.reply_hide_threshold) + else: + comments.filter(PostReply.score > -20) + if sort_by == 'hot': comments = comments.order_by(desc(PostReply.ranking)) elif sort_by == 'top': diff --git a/app/static/styles.css b/app/static/styles.css index 67dc0161..79d44e32 100644 --- a/app/static/styles.css +++ b/app/static/styles.css @@ -621,6 +621,10 @@ div.navbar { margin-bottom: 3px; } +form h5 { + padding-top: 12px; +} + .coolfieldset, .coolfieldset.expanded { border: 1px solid #ddd; border-radius: 5px; diff --git a/app/static/styles.scss b/app/static/styles.scss index f12ce699..b0330edb 100644 --- a/app/static/styles.scss +++ b/app/static/styles.scss @@ -189,6 +189,12 @@ div.navbar { margin-bottom: 3px; } +form { + h5 { + padding-top: 12px; + } +} + .coolfieldset, .coolfieldset.expanded{ border:1px solid $light-grey; border-radius: 5px; diff --git a/app/templates/post/post.html b/app/templates/post/post.html index a79de916..ed0a4a4d 100644 --- a/app/templates/post/post.html +++ b/app/templates/post/post.html @@ -80,7 +80,7 @@ {% if comment['comment'].author.deleted -%} [deleted] {% else -%} - {% if comment['comment'].author.avatar_id and comment['comment'].score > -10 and not low_bandwidth -%} + {% if comment['comment'].author.avatar_id and comment['comment'].score > reply_collapse_threshold and not low_bandwidth -%} {% endif -%} @@ -122,7 +122,7 @@ {% endwith -%}
- {% if comment['comment'].score <= -10 -%} + {% if comment['comment'].score <= reply_collapse_threshold -%} diff --git a/app/templates/user/edit_settings.html b/app/templates/user/edit_settings.html index 5d142a6a..2ae7dad2 100644 --- a/app/templates/user/edit_settings.html +++ b/app/templates/user/edit_settings.html @@ -26,6 +26,10 @@ {{ render_field(form.email_unread) }}