Skip to content

Commit 2a6bfc6

Browse files
committed
updates redirect on update to check participant_ids instead of conversation_participants
1 parent 7a25538 commit 2a6bfc6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

app/controllers/better_together/conversations_controller.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
5757
@message = @conversation.messages.build
5858

5959
turbo_stream_response = lambda do
60-
if @conversation.conversation_participants.exists?(person_id: helpers.current_person)
60+
if @conversation.participant_ids.include?(helpers.current_person.id)
6161
render turbo_stream: turbo_stream.replace(
6262
helpers.dom_id(@conversation),
6363
partial: 'better_together/conversations/conversation_content',
@@ -69,7 +69,7 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
6969
end
7070

7171
html_response = lambda do
72-
if @conversation.conversation_participants.exists?(person_id: helpers.current_person)
72+
if @conversation.participant_ids.include?(helpers.current_person.id)
7373
redirect_to @conversation
7474
else
7575
redirect_to conversations_path
@@ -123,6 +123,8 @@ def show # rubocop:todo Metrics/MethodLength, Metrics/AbcSize
123123
def leave_conversation # rubocop:todo Metrics/MethodLength
124124
authorize @conversation
125125

126+
flash[:error] if @conversation.participant_ids.size == 1
127+
126128
participant = @conversation.conversation_participants.find_by(person: helpers.current_person)
127129

128130
if participant.destroy

0 commit comments

Comments
 (0)