discourse/app/models/topic_participant_groups_summary.rb
Vinoth Kannan d4bfd441ba
FEATURE: display PM participant group names in the topics list. (#21677)
After this change, we can view all participant group names on the topic list page.

Co-authored-by: Régis Hanol <regis@hanol.fr>
2023-05-31 19:32:06 +05:30

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