diff --git a/app/views/messages/_threads.html.erb b/app/views/messages/_threads.html.erb index 7900a85..e7f2ba1 100644 --- a/app/views/messages/_threads.html.erb +++ b/app/views/messages/_threads.html.erb @@ -1,4 +1,5 @@ <% threads = message.threads.to_a.select { |t| (t.messages_count || t.messages.active.count) > 0 } %> +<% unread_thread_ids = Membership.where(room_id: threads.map(&:id), user_id: Current.user.id).unread.pluck(:room_id) %>
<% threads.each do |thread| %> <% # Get users who have posted in the thread, ordered by their first message timestamp %> @@ -22,7 +23,11 @@
<%= pluralize(reply_count, 'reply', 'replies') %> <% if reply_count > 0 %> - Last reply <%= local_datetime_tag thread.last_active_at, style: :relative %> + <% if unread_thread_ids.include?(thread.id) %> + Last reply <%= local_datetime_tag thread.last_active_at, style: :relative %> + <% else %> + Last reply <%= local_datetime_tag thread.last_active_at, style: :relative %> + <% end %> <% end %> <% end %> <% end %>