Sha256: 41c0b89e972ade24d974422c3da54f8b12312941d069dd63237706c696a4f583

Contents?: true

Size: 490 Bytes

Versions: 15

Compression:

Stored size: 490 Bytes

Contents

module WithNotifications
  extend ActiveSupport::Concern

  def unread_messages
    messages_in_organization.where read: false
  end

  def unread_notifications
    # TODO: message and discussion should trigger a notification instead of being one
    all = notifications_in_organization.where(read: false) + unread_messages + unread_discussions
    all.sort_by(&:created_at).reverse
  end

  def read_notification!(target)
    notifications.find_by(target: target)&.mark_as_read!
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mumuki-domain-9.23.0 app/models/concerns/with_notifications.rb
mumuki-domain-9.22.1 app/models/concerns/with_notifications.rb
mumuki-domain-9.22.0 app/models/concerns/with_notifications.rb
mumuki-domain-9.21.0 app/models/concerns/with_notifications.rb
mumuki-domain-9.20.0 app/models/concerns/with_notifications.rb
mumuki-domain-9.19.0 app/models/concerns/with_notifications.rb
mumuki-domain-9.18.0 app/models/concerns/with_notifications.rb
mumuki-domain-9.17.0 app/models/concerns/with_notifications.rb
mumuki-domain-9.16.0 app/models/concerns/with_notifications.rb
mumuki-domain-9.15.0 app/models/concerns/with_notifications.rb
mumuki-domain-9.14.1 app/models/concerns/with_notifications.rb
mumuki-domain-9.14.0 app/models/concerns/with_notifications.rb
mumuki-domain-9.13.1 app/models/concerns/with_notifications.rb
mumuki-domain-9.13.0 app/models/concerns/with_notifications.rb
mumuki-domain-9.12.0 app/models/concerns/with_notifications.rb