Files
danbooru/app/components/comment_component.rb
evazion 07bdc6eab0 comments: rework thresholded comments.
Previously thresholded comments were hidden completely. You had to click
the "Show X hidden comments" button to unhide all hidden comments in a
thread. Now it works like this:

* When a comment is below your threshold, the comment text is hidden and
  replaced by a `[hidden]` link, which you can click to unhide the comment.

* When a comment is at half your threshold (for example, your threshold
  is -8 but the comment is at -4), then the comment is greyed out.

This means that comments aren't completely hidden, they're just
collapsed, so you can see the commenter and the score without unhiding
the comment. It also means you don't have to scroll back up to unhide a
comment, and threads aren't disrupted by comments being secretly
hidden (which is confusing when people are replying to hidden comments,
which forces you to go back up and unhide to find).
2021-01-19 04:07:33 -06:00

31 lines
881 B
Ruby

# frozen_string_literal: true
class CommentComponent < ApplicationComponent
attr_reader :comment, :context, :dtext_data, :show_deleted, :current_user
delegate :link_to_user, :time_ago_in_words_tagged, :format_text, to: :helpers
def initialize(comment:, current_user:, context: nil, dtext_data: nil, show_deleted: false)
@comment = comment
@context = context
@dtext_data = dtext_data
@show_deleted = show_deleted
@current_user = current_user
end
def render?
!comment.is_deleted? || show_deleted || current_user.is_moderator?
end
def dimmed?
!comment.is_sticky? && comment.score < current_user.comment_threshold/2.0
end
def thresholded?
!comment.is_sticky? && comment.score < current_user.comment_threshold
end
def has_moderation_reports?
policy(ModerationReport).show? && comment.moderation_reports.present?
end
end