messages_helper.rb 341 B

1234567891011
  1. module MessagesHelper
  2. def unread_messages_count(user)
  3. counter = 0
  4. for conversation_participation in user.conversation_participations
  5. counter += conversation_participation.conversation.messages.select do |message|
  6. message.created_at > conversation_participation.viewed_at
  7. end.count
  8. end
  9. counter
  10. end
  11. end