From 9d8d6b023ce3390f3ccf9808e630505a15ebebe6 Mon Sep 17 00:00:00 2001 From: nfoy Date: Sat, 26 Apr 2014 23:45:18 -0400 Subject: Messages now check if they're read/unread except when creating a message. --- app/views/pms/index.html.erb | 97 +++++++++++++++++++++++++++++--------------- app/views/pms/show.html.erb | 8 ++-- 2 files changed, 68 insertions(+), 37 deletions(-) diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb index a13705a..560cf38 100644 --- a/app/views/pms/index.html.erb +++ b/app/views/pms/index.html.erb @@ -1,4 +1,10 @@ -

Conversations

+

Your Conversations

+ +<%= link_to 'Start a new conversation', new_pm_path %> +
+ +

Unread Conversations

+<% conversations = current_user.mailbox.conversations %> @@ -6,43 +12,68 @@ - <% conversations = current_user.mailbox.conversations %> - <% if !conversations.empty? %> - <%# require 'pp' %> - <%= conversations.class %> - - - - - - <% conversations.each do |conversation| %> - <% receipts = conversation.receipts_for current_user %> - <%# receipts.each do |receipt| %> - <% message = receipts.last.message %> - - + + + + + <% conversations.each do |conversation| %> + <% receipts = conversation.receipts_for current_user %> + <% if conversation.is_unread?(current_user) && receipts.last.message.sender != current_user %> + <% message = receipts.last.message %> + + - - - - - <%# end %> + <% end %> + + + + + <% end %> - - <% else %> - <% end %> - - +
WithSubjectBody
- <% people = conversation.participants %> - <% people.each do |person| %> - <% unless person == current_user %> - <%= truncate(person.user_name, length: 20) %> - <% end %> +
WithSubjectBody
+ <% people = conversation.participants %> + <% people.each do |person| %> + <% unless person == current_user %> + <%= truncate(person.user_name, length: 20) %> <% end %> - <%= truncate(conversation.subject, length: 30) %><%= truncate(message.body, length: 42) %><%= link_to 'View', @pms.find_by(conversation: conversation) %>
<%= truncate(conversation.subject, length: 30) %><%= truncate(message.body, length: 42) %><%= link_to 'View', @pms.find_by(conversation: conversation) %>

No Messages


+

Read Conversations

+<% conversations = current_user.mailbox.conversations %> -<%= link_to 'New Pm', new_pm_path %> + + + + + + + + + + + + <% conversations.each do |conversation| %> + <% receipts = conversation.receipts_for current_user %> + <% if conversation.is_read?(current_user) || receipts.last.message.sender == current_user %> + <% message = receipts.last.message %> + + + + + + + <% end %> + <% end %> + + +
WithSubjectBody
+ <% people = conversation.participants %> + <% people.each do |person| %> + <% unless person == current_user %> + <%= truncate(person.user_name, length: 20) %> + <% end %> + <% end %> + <%= truncate(conversation.subject, length: 30) %><%= truncate(message.body, length: 42) %><%= link_to 'View', @pms.find_by(conversation: conversation) %>
\ No newline at end of file diff --git a/app/views/pms/show.html.erb b/app/views/pms/show.html.erb index 64dd66e..ca8d9bf 100644 --- a/app/views/pms/show.html.erb +++ b/app/views/pms/show.html.erb @@ -4,10 +4,10 @@ <% receps.each do |recep| %> <% #unless recep == @pm.conversation.last_sender %> <%= recep.user_name %> - <%= "and" %> + <%= "," %> <% #end %> <% end %> - <%= "the NSA" %> + <%= "and the NSA" %>

@@ -22,7 +22,7 @@

________________________________________________

- <%= message.sender.user_name %> + <%= message.sender.user_name %> <%= ":" %> <%= message.body %>

@@ -43,5 +43,5 @@ <% end %>

- +<% @pm.conversation.mark_as_read(current_user) %> <%= link_to 'Back', pms_path %> -- cgit v1.2.3