Skip to content

Commit cbd30fa

Browse files
committed
extracts expression for current user in conversation participants list into a variable
1 parent edd8a15 commit cbd30fa

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
@@ -56,8 +56,10 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
5656
.order(:created_at)
5757
@message = @conversation.messages.build
5858

59+
is_current_user_in_conversation = @conversation.participant_ids.include?(helpers.current_person.id)
60+
5961
turbo_stream_response = lambda do
60-
if @conversation.participant_ids.include?(helpers.current_person.id)
62+
if is_current_user_in_conversation
6163
render turbo_stream: turbo_stream.replace(
6264
helpers.dom_id(@conversation),
6365
partial: 'better_together/conversations/conversation_content',
@@ -69,7 +71,7 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
6971
end
7072

7173
html_response = lambda do
72-
if @conversation.participant_ids.include?(helpers.current_person.id)
74+
if is_current_user_in_conversation
7375
redirect_to @conversation
7476
else
7577
redirect_to conversations_path

0 commit comments

Comments
 (0)