Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

avoid instantiating the notification menu twice for the header

ulfertse65ca0440085
diff --git a/app/components/notifications/index_page_header_component.rb b/app/components/notifications/index_page_header_component.rb
index d82bd0be5a2..87430ca55f4 100644
--- a/app/components/notifications/index_page_header_component.rb
+++ b/app/components/notifications/index_page_header_component.rb
@@ -61,21 +61,26 @@ module Notifications
def current_section
return @current_section if defined?(@current_section)
- @current_section = Notifications::Menu
- .new(params:, current_user: User.current)
+ @current_section = notifications_menu
.selected_menu_group
end
def current_item
return @current_item if defined?(@current_item)
- @current_item = Notifications::Menu
- .new(params:, current_user: User.current)
+ @current_item = notifications_menu
.selected_menu_item
end
def first_menu_item?
current_item&.href == notifications_path
end
+
+ def notifications_menu
+ # Instantiating the Notifications::Menu is currently costly as it fires
+ # three database queries right away.
+ @notifications_menu ||= Notifications::Menu
+ .new(params:, current_user: User.current)
+ end
end
end