diff --git a/CHANGELOG.md b/CHANGELOG.md index 977e23bfc..0b080a19b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,19 @@ * You can now see when a post has deleted comments. Deleted comments are now replaced with the word `[deleted]`, instead of being completely hidden. +* The way downvoted comments work has changed. Instead of comments being + completely hidden when they get downvoted, and having to click "Show X hidden + comments" to see them, now they get collapsed and marked as `[hidden]`, and + you click the comment itself to unhide it. + +* The default comment threshold has been lowered to -8. This means that + comments are now hidden at -8 and greyed out at -4. If your threshold was + higher than this, it has been reset to -8. You can go to your settings to + change this. + +* The maximum comment threshold is now 5 and the minumum threshold is now + -100. You can't set your threshold any higher or lower than this. + ### API Changes * Deleted comments now have some of their fields hidden in the API. The diff --git a/app/components/comment_component.rb b/app/components/comment_component.rb index 5ea7d34a1..1fbc085c4 100644 --- a/app/components/comment_component.rb +++ b/app/components/comment_component.rb @@ -12,11 +12,11 @@ class CommentComponent < ApplicationComponent end def dimmed? - comment.is_deleted? || (!comment.is_sticky? && comment.score < current_user.comment_threshold/2.0) + comment.is_deleted? || (!comment.is_sticky? && comment.score <= current_user.comment_threshold/2.0) end def thresholded? - !comment.is_deleted? && !comment.is_sticky? && comment.score < current_user.comment_threshold + !comment.is_deleted? && !comment.is_sticky? && comment.score <= current_user.comment_threshold end def redact_deleted? diff --git a/app/models/user.rb b/app/models/user.rb index b5c8c39f2..f2d6361aa 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -81,7 +81,7 @@ class User < ApplicationRecord attribute :last_logged_in_at, default: -> { Time.zone.now } attribute :last_forum_read_at, default: "1960-01-01 00:00:00" attribute :last_ip_addr - attribute :comment_threshold, default: 0 + attribute :comment_threshold, default: -8 attribute :default_image_size, default: "large" attribute :favorite_tags attribute :blacklisted_tags, default: DEFAULT_BLACKLIST @@ -108,7 +108,7 @@ class User < ApplicationRecord validates_inclusion_of :default_image_size, :in => %w(large original) validates_inclusion_of :per_page, in: (1..PostSets::Post::MAX_PER_PAGE) validates_confirmation_of :password - validates_presence_of :comment_threshold + validates :comment_threshold, inclusion: { in: (-100..5) } before_validation :normalize_blacklisted_tags before_create :promote_to_admin_if_first_user has_many :artist_versions, foreign_key: :updater_id diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 0c4e32fc8..3915d25ad 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -45,7 +45,7 @@ <%= f.input :default_image_size, hint: "Show full original images or resized #{Danbooru.config.large_image_width}px width samples.", label: "Default image width", collection: [["850px", "large"], ["original", "original"]], include_blank: false %> <%= f.input :receive_email_notifications, as: :select, include_blank: false, collection: [["Yes", "true"], ["No", "false"]], hint: "Receive an email when you receive a new dmail." %> <%= f.input :time_zone, include_blank: false, hint: "The timezone to use for timestamps." %> - <%= f.input :comment_threshold, hint: "Comments below this score will be hidden by default" %> + <%= f.input :comment_threshold, hint: "Comments at or below this score will be hidden by default.", input_html: { min: -100, max: 5 } %> <%= f.input :blacklisted_tags, hint: "Posts with these tags will be hidden. Put each tag on a separate line. View help.".html_safe, :input_html => {:size => "40x5", :data => {:autocomplete => "tag-query"}} %> diff --git a/script/fixes/073_change_default_comment_threshold.rb b/script/fixes/073_change_default_comment_threshold.rb new file mode 100755 index 000000000..fbebb018f --- /dev/null +++ b/script/fixes/073_change_default_comment_threshold.rb @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +require_relative "../../config/environment" + +User.transaction do + users = User.where("comment_threshold > ?", User.anonymous.comment_threshold) + p users.count + users.update_all(comment_threshold: User.anonymous.comment_threshold) + + users = User.where("comment_threshold < ?", -100) + p users.count + users.update_all(comment_threshold: -100) +end