Files
grecia/app/components/layout/notification_item_component.rb
Javi Martín 7f749bb9bb Add and apply Style/CollectionQuerying rubocop rule
This rule was added in rubocop 1.77. We were following it most of the
time. It makes the code more readable in my humble opinion.
2025-11-05 14:27:12 +01:00

30 lines
576 B
Ruby

class Layout::NotificationItemComponent < ApplicationComponent
attr_reader :user
def initialize(user)
@user = user
end
def render?
user.present? && !Rails.application.multitenancy_management_mode?
end
private
def text
t("layouts.header.notification_item.new_notifications", count: unread_notifications.count)
end
def notifications_class
if unread_notifications.any?
"unread-notifications"
else
"no-notifications"
end
end
def unread_notifications
user.notifications.unread
end
end