Files
grecia/app/components/layout/notification_item_component.rb
Javi Martín e266e0e0e2 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.
2021-02-18 14:45:48 +01:00

26 lines
490 B
Ruby

class Layout::NotificationItemComponent < ApplicationComponent
attr_reader :user
def initialize(user)
@user = user
end
private
def text
t("layouts.header.notification_item.new_notifications", count: unread_notifications.count)
end
def notifications_class
if unread_notifications.count > 0
"unread-notifications"
else
"no-notifications"
end
end
def unread_notifications
user.notifications.unread
end
end