% new_message ||= false %> <% current_author = defined?(current_user) ? current_user : send(BulletTrain::Conversations.current_participant_helper_method) %> <% current_user_message = message.author == current_author %> <% avatar = capture do %> <% if message.membership %> <% elsif message.participant %>
<% end %> <% end %> <% next_message ||= message.next_message %> <%# A message series is a series of messages by the same user, each message within 5 minutes of the previous message. It has nothing to do with replies and message threads %> <% next_message_in_series = (message.author == next_message&.author) && (message.created_at > next_message.created_at - 5.minutes) && (message.parent_message_id == next_message&.parent_message_id || message.id == next_message.parent_message_id)%> <% if next_message_in_series %> <% avatar = nil %> <% end %> <%# We set this to true when rendering the messages for the reply view. All messages in the thread are shown in order without any other messages from the conversation %> <% show_as_thread ||= false %> <%# placeholder messages are used when displaying a reply to a message that we need to show out of order with the rest %> <% placeholder_message ||= false %> <% if avatar.nil? %> <% avatar = capture do %> <% end %> <% end %> <% rounding_modifier = message_corner_class(next_message_in_series, current_user_message) %> <% timestamp = next_message_in_series || show_as_thread ? '' : time_ago_in_words(message.created_at) + " ago" %> <% threaded_message = message.threaded? %> <% thread_started_by_current_user = message.thread_origin_user == current_author %> <% last_message_in_thread = !placeholder_message && threaded_message && (message.next_message.nil? || message.next_message.thread_id != message.thread_id)%> <% out_of_thread_message = !show_as_thread && threaded_message && message.reply? && message.previous_message != message.previous_message_in_thread %> <% has_replies = message.replies.any? && message.next_message == message.next_message_in_thread %> <% border_side = thread_started_by_current_user ? :left : :right %> <% show_borders = !show_as_thread && threaded_message %> <% if out_of_thread_message %> <%= render 'account/shared/message', message: message.thread_origin_message, next_message: message, placeholder_message: true, show_as_thread: show_as_thread %> <% end %>