Browse Source

feat: move notification helper methods to notifications_helper.rb

pull/2131/head
natdeanlewissoftwire 2 years ago
parent
commit
3535456519
  1. 16
      app/helpers/application_helper.rb
  2. 17
      app/helpers/notifications_helper.rb
  3. 2
      app/views/layouts/application.html.erb

16
app/helpers/application_helper.rb

@ -31,22 +31,6 @@ module ApplicationHelper
!current_page?(notifications_path) && (authenticated_user_has_notifications? || unauthenticated_user_has_notifications?) !current_page?(notifications_path) && (authenticated_user_has_notifications? || unauthenticated_user_has_notifications?)
end end
def notification_count
if current_user.present?
current_user.active_unread_notifications.count
else
Notification.active_unauthenticated_notifications.count
end
end
def notification
if current_user.present?
current_user.newest_active_unread_notification
else
Notification.newest_active_unauthenticated_notification
end
end
private private
def paginated_title(title, pagy) def paginated_title(title, pagy)

17
app/helpers/notifications_helper.rb

@ -0,0 +1,17 @@
module NotificationsHelper
def notification_count
if current_user.present?
current_user.active_unread_notifications.count
else
Notification.active_unauthenticated_notifications.count
end
end
def notification
if current_user.present?
current_user.newest_active_unread_notification
else
Notification.newest_active_unauthenticated_notification
end
end
end

2
app/views/layouts/application.html.erb

@ -100,7 +100,7 @@
end %> end %>
<% if notifications_to_display? %> <% if notifications_to_display? %>
<%= render "notifications/notification_banner", notification_count:, notification: %> <%= render "notifications/notification_banner" %>
<% end %> <% end %>
<% feedback_link = govuk_link_to "giving us your feedback (opens in a new tab)", t("feedback_form"), rel: "noreferrer noopener", target: "_blank" %> <% feedback_link = govuk_link_to "giving us your feedback (opens in a new tab)", t("feedback_form"), rel: "noreferrer noopener", target: "_blank" %>

Loading…
Cancel
Save