Skip to content

Commit 356d19e

Browse files
committed
Improve preloading of conversation participant data
1 parent f520339 commit 356d19e

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

app/policies/better_together/conversation_policy.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def leave_conversation?
3737
# Returns the people that the agent is permitted to message
3838
def permitted_participants
3939
if permitted_to?('manage_platform')
40-
BetterTogether::Person.all
40+
BetterTogether::Person.includes(:string_translations).all
4141
else
4242
role = BetterTogether::Role.find_by(identifier: 'platform_manager')
4343
manager_ids = BetterTogether::PersonPlatformMembership.where(role_id: role.id).pluck(:member_id)
@@ -46,7 +46,7 @@ def permitted_participants
4646
'preferences @> ?', { receive_messages_from_members: true }.to_json
4747
)
4848

49-
BetterTogether::Person.where(id: manager_ids).or(opted_in).distinct
49+
BetterTogether::Person.includes(:string_translations).where(id: manager_ids).or(opted_in).distinct
5050
end
5151
end
5252

app/views/better_together/conversations/_conversation_content.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</h4>
1313
<% end %>
1414
<div class="conversation-participants w-100 d-flex align-items-top justify-content-evenly overflow-auto">
15-
<%= render partial: 'better_together/people/mention' , collection: conversation.participants, as: :person,
15+
<%= render partial: 'better_together/people/mention' , collection: conversation.participants.includes(:string_translations).with_attached_profile_image, as: :person,
1616
locals: { flex_layout: 'flex-column' , flex_align_items: 'center' } %>
1717
</div>
1818
<div data-bs-toggle="tooltip" title="<%= t('.options_tooltip') %>" class="align-self-center mx-4">

app/views/better_together/people/_mention.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<%= profile_image_tag(person, class: 'mention', size: 50) %>
88
</div>
99
<div class="h-50 align-self-top">
10-
<a class="text-decoration-none identity-name stretched-link" href="<%= policy(person).show? ? person_path(person) : 'test' %>">
10+
<a class="text-decoration-none identity-name stretched-link" href="<%= policy(person).show? ? person_path(person) : nil %>">
1111
<%= person.name %>
1212
</a>
1313
</div>

0 commit comments

Comments
 (0)