Simplify code to display text of new notifications
We couldn't do this refactoring earlier because we weren't using the unread notifications count. This was fixed in the previous commit.
This commit is contained in:
@@ -8,25 +8,17 @@ class Layout::NotificationItemComponent < ApplicationComponent
|
||||
private
|
||||
|
||||
def text
|
||||
if unread_notifications?
|
||||
t("layouts.header.notification_item.new_notifications", count: unread_notifications.count)
|
||||
else
|
||||
t("layouts.header.notification_item.no_notifications")
|
||||
end
|
||||
t("layouts.header.notification_item.new_notifications", count: unread_notifications.count)
|
||||
end
|
||||
|
||||
def notifications_class
|
||||
if unread_notifications?
|
||||
if unread_notifications.count > 0
|
||||
"unread-notifications"
|
||||
else
|
||||
"no-notifications"
|
||||
end
|
||||
end
|
||||
|
||||
def unread_notifications?
|
||||
unread_notifications.count > 0
|
||||
end
|
||||
|
||||
def unread_notifications
|
||||
user.notifications.unread
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user