added notification_count
This commit is contained in:
parent
43474a6c92
commit
dec91d474d
|
@ -47,6 +47,14 @@ module ApplicationHelper
|
|||
count.count
|
||||
end
|
||||
|
||||
def notification_count
|
||||
return 0 unless user_signed_in?
|
||||
count = Notification.for(current_user).where(new: true)
|
||||
return nil if count.nil?
|
||||
return nil unless count.count > 0
|
||||
count.count
|
||||
end
|
||||
|
||||
def privileged?(user)
|
||||
(current_user && (current_user == user || current_user.admin?)) ? true : false
|
||||
end
|
||||
|
|
|
@ -1 +1 @@
|
|||
= nav_entry "Notifications", "/notifications/index"
|
||||
= nav_entry "Notifications", "/notifications/index", badge: notification_count
|
|
@ -59,4 +59,5 @@
|
|||
= time_ago_in_words notification.target.created_at
|
||||
ago
|
||||
.notification--icon
|
||||
%i.fa.fa-comments
|
||||
%i.fa.fa-comments
|
||||
- Notification.for(current_user).update_all(new: false)
|
Loading…
Reference in New Issue