FEATURE: unread pms go in front of notification report

also refactor fat controller
This commit is contained in:
Sam
2014-02-13 17:12:17 +11:00
parent 4ff6780758
commit e8aa85d783
3 changed files with 72 additions and 11 deletions

View File

@ -3,17 +3,8 @@ class NotificationsController < ApplicationController
before_filter :ensure_logged_in
def index
notifications = current_user.notifications.recent.includes(:topic)
notifications = Notification.recent_report(current_user)
if notifications.present?
notifications += current_user.notifications
.order('created_at desc')
.where(read: false, notification_type: Notification.types[:private_message])
.where('id < ?', notifications.last.id)
.limit(5)
end
notifications = notifications.to_a
current_user.saw_notification_id(notifications.first.id) if notifications.present?
current_user.reload
current_user.publish_notifications_state