mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Flag count in post menu
This change shows a notification number besides the flag icon in the post menu if there is reviewable content associated with the post. Additionally, if there is pending stuff to review, the icon has a red background. We have also removed the list of links below a post with the flag status. A reviewer is meant to click the number beside the flag icon to view the flags. As a consequence of losing those links, we've removed the ability to undo or ignore flags below a post.
This commit is contained in:
@@ -15,7 +15,8 @@ class TopicView
|
||||
:print,
|
||||
:message_bus_last_id,
|
||||
:queued_posts_enabled,
|
||||
:personal_message
|
||||
:personal_message,
|
||||
:can_review_topic
|
||||
)
|
||||
|
||||
attr_accessor(
|
||||
@@ -100,6 +101,7 @@ class TopicView
|
||||
@draft_key = @topic.draft_key
|
||||
@draft_sequence = DraftSequence.current(@user, @draft_key)
|
||||
|
||||
@can_review_topic = @guardian.can_review_topic?(@topic)
|
||||
@queued_posts_enabled = NewPostManager.queue_enabled?
|
||||
@personal_message = @topic.private_message?
|
||||
end
|
||||
@@ -410,16 +412,32 @@ class TopicView
|
||||
@all_post_actions ||= PostAction.counts_for(@posts, @user)
|
||||
end
|
||||
|
||||
def all_active_flags
|
||||
@all_active_flags ||= ReviewableFlaggedPost.counts_for(@posts)
|
||||
end
|
||||
|
||||
def links
|
||||
@links ||= TopicLink.topic_map(@guardian, @topic.id)
|
||||
end
|
||||
|
||||
def reviewable_counts
|
||||
if @reviewable_counts.blank?
|
||||
|
||||
# Create a hash with counts by post so we can quickly look up whether there is reviewable content.
|
||||
@reviewable_counts = {}
|
||||
Reviewable.
|
||||
where(target_type: 'Post', target_id: filtered_post_ids).
|
||||
includes(:reviewable_scores).each do |r|
|
||||
|
||||
for_post = (@reviewable_counts[r.target_id] ||= { total: 0, pending: 0, reviewable_id: r.id })
|
||||
r.reviewable_scores.each do |s|
|
||||
for_post[:total] += 1
|
||||
for_post[:pending] += 1 if s.pending?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@reviewable_counts
|
||||
end
|
||||
|
||||
def pending_posts
|
||||
ReviewableQueuedPost.pending.where(created_by: @user, topic: @topic).order(:created_at)
|
||||
@pending_posts ||= ReviewableQueuedPost.pending.where(created_by: @user, topic: @topic).order(:created_at)
|
||||
end
|
||||
|
||||
def actions_summary
|
||||
|
||||
Reference in New Issue
Block a user