Skip to content

Commit 9f67599

Browse files
committed
Only load conversation list on new and index actions
1 parent 3c34dd8 commit 9f67599

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

app/controllers/better_together/conversations_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module BetterTogether
44
# Handles managing conversations
55
class ConversationsController < ApplicationController
66
before_action :authenticate_user!
7-
before_action :set_conversations
7+
before_action :set_conversations, only: %i[index new]
88
before_action :set_conversation, only: %i[show]
99

1010
helper_method :available_participants
@@ -30,7 +30,7 @@ def create
3030
end
3131

3232
def show # rubocop:todo Metrics/MethodLength
33-
@messages = @conversation.messages.with_rich_text_content.includes(sender: [ :string_translations ]).order(:created_at)
33+
@messages = @conversation.messages.with_all_rich_text.includes(sender: [ :string_translations ]).order(:created_at)
3434
@message = @conversation.messages.build
3535

3636
respond_to do |format|
@@ -63,11 +63,11 @@ def conversation_params
6363
end
6464

6565
def set_conversation
66-
@conversation = @conversations.find(params[:id])
66+
@conversation = helpers.current_person.conversations.includes(:participants).find(params[:id])
6767
end
6868

6969
def set_conversations
70-
@conversations = helpers.current_person.conversations.order(updated_at: :desc)
70+
@conversations = helpers.current_person.conversations.includes(messages: [:sender], participants: [:string_translations, :contact_detail, { profile_image_attachment: :blob }]).order(updated_at: :desc).distinct(:id)
7171
end
7272

7373
def platform_manager_ids

0 commit comments

Comments
 (0)