From e266e0e0e29fb9bd44fbd2716ec92542361aa780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 16 Feb 2021 01:26:57 +0100 Subject: [PATCH] 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. --- app/components/layout/notification_item_component.rb | 12 ++---------- config/locales/en/general.yml | 2 +- config/locales/es/general.yml | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/app/components/layout/notification_item_component.rb b/app/components/layout/notification_item_component.rb index c63205f12..c620180b0 100644 --- a/app/components/layout/notification_item_component.rb +++ b/app/components/layout/notification_item_component.rb @@ -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 diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 6f6672013..450f51b8a 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -249,8 +249,8 @@ en: new_notifications: one: You have a new notification other: You have %{count} new notifications + zero: "You don't have new notifications" notifications: Notifications - no_notifications: "You don't have new notifications" sdg: "SDG" notifications: index: diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index d1fff5341..67bc57a8a 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -249,8 +249,8 @@ es: new_notifications: one: Tienes una nueva notificación other: Tienes %{count} notificaciones nuevas + zero: "No tienes notificaciones nuevas" notifications: Notificaciones - no_notifications: "No tienes notificaciones nuevas" sdg: "ODS" notifications: index: