Messages

<% @conversations.each do |conversation| %> <%# unseen is only set on 'received' message refs (see controller create method). It would be more efficient to use a single query in controller rather than in this loop but there shouldn't be huge numbers of conversations (Todo).%> <% end %>
<%= current_user.vendor ? "Buyer name" : "Vendor name" %> New messages Message count Last sent/received Recipient seen
<%= link_to conversation.otherparty.displayname, profile_path(conversation.otherparty) %> <% if conversation.unseen_cnt > 0 %> <%= link_to "#{conversation.unseen_cnt} new", show_conversation_path(conversation.otherparty), class: 'btn btn-success' %> <%else%> <%= conversation.unseen_cnt %> <%end%> <%= conversation.cnt %> <%= conversation.newest_message_date.in_time_zone(current_user.timezone).strftime('%F') %><%if conversation.sent_anything == false %> n/a <%else%> <%=image_tag('checkmark.svg') unless MessageRef.where(user: conversation.otherparty, otherparty: current_user, direction: 'received', unseen: 1).count > 0 %> <%end%> <%= link_to 'View', show_conversation_path(conversation.otherparty), class: 'btn btn-primary' %> <%= link_to 'Delete', "#delete_#{conversation.otherparty.id}", class: 'btn btn-danger' %>

To send a message, visit the user's profile and click the send message link.

<% @conversations.each do |conversation| %> <% end %>