mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 10:53:43 +08:00
d4bfd441ba
After this change, we can view all participant group names on the topic list page. Co-authored-by: Régis Hanol <regis@hanol.fr>
32 lines
624 B
Ruby
32 lines
624 B
Ruby
# frozen_string_literal: true
|
|
|
|
# This is used on a topic page
|
|
class TopicParticipantGroupsSummary
|
|
attr_reader :topic, :options
|
|
|
|
def initialize(topic, options = {})
|
|
@topic = topic
|
|
@options = options
|
|
@group = options[:group]
|
|
end
|
|
|
|
def summary
|
|
group_participants.compact
|
|
end
|
|
|
|
def group_participants
|
|
return [] if group_ids.blank?
|
|
group_ids.map { |id| group_lookup[id] }
|
|
end
|
|
|
|
def group_ids
|
|
ids = topic.allowed_group_ids
|
|
ids = ids - [@group.id] if @group.present?
|
|
ids
|
|
end
|
|
|
|
def group_lookup
|
|
@group_lookup ||= options[:group_lookup] || GroupLookup.new(group_ids)
|
|
end
|
|
end
|