mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-16 19:19:59 +01:00
added notification_count
This commit is contained in:
parent
43474a6c92
commit
dec91d474d
3 changed files with 11 additions and 2 deletions
app
|
@ -47,6 +47,14 @@ module ApplicationHelper
|
||||||
count.count
|
count.count
|
||||||
end
|
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)
|
def privileged?(user)
|
||||||
(current_user && (current_user == user || current_user.admin?)) ? true : false
|
(current_user && (current_user == user || current_user.admin?)) ? true : false
|
||||||
end
|
end
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
= nav_entry "Notifications", "/notifications/index"
|
= nav_entry "Notifications", "/notifications/index", badge: notification_count
|
|
@ -60,3 +60,4 @@
|
||||||
ago
|
ago
|
||||||
.notification--icon
|
.notification--icon
|
||||||
%i.fa.fa-comments
|
%i.fa.fa-comments
|
||||||
|
- Notification.for(current_user).update_all(new: false)
|
Loading…
Reference in a new issue