Fix number of new notifications

We were displaying the total number of notifications with a message "You
have N unread notifications", but were using the total number of
notifications instead of the unread ones.
This commit is contained in:
Javi Martín
2021-02-16 01:24:33 +01:00
parent 0839c5ea75
commit fb88e0b77c
3 changed files with 11 additions and 5 deletions

View File

@@ -9,7 +9,7 @@ class Layout::NotificationItemComponent < ApplicationComponent
def text
if unread_notifications?
t("layouts.header.notification_item.new_notifications", count: user.notifications_count)
t("layouts.header.notification_item.new_notifications", count: unread_notifications.count)
else
t("layouts.header.notification_item.no_notifications")
end
@@ -24,6 +24,10 @@ class Layout::NotificationItemComponent < ApplicationComponent
end
def unread_notifications?
user.notifications.unread.count > 0
unread_notifications.count > 0
end
def unread_notifications
user.notifications.unread
end
end