mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Preload sidebar categories when lazy loading categories (#25332)
This fixes a bug where the sidebar categories would not be loaded when the categories were lazy loaded because the sidebar uses the preloaded category list, which was empty.
This commit is contained in:
@@ -106,15 +106,26 @@ class Site
|
||||
end
|
||||
|
||||
def categories
|
||||
if @guardian.can_lazy_load_categories?
|
||||
preloaded_category_ids = []
|
||||
if @guardian.authenticated?
|
||||
preloaded_category_ids.concat(@guardian.user.secured_sidebar_category_ids(@guardian))
|
||||
end
|
||||
end
|
||||
|
||||
@categories ||=
|
||||
begin
|
||||
categories = []
|
||||
|
||||
self.class.all_categories_cache.each do |category|
|
||||
if @guardian.can_see_serialized_category?(
|
||||
category_id: category[:id],
|
||||
read_restricted: category[:read_restricted],
|
||||
)
|
||||
if (
|
||||
!@guardian.can_lazy_load_categories? ||
|
||||
preloaded_category_ids.include?(category[:id])
|
||||
) &&
|
||||
@guardian.can_see_serialized_category?(
|
||||
category_id: category[:id],
|
||||
read_restricted: category[:read_restricted],
|
||||
)
|
||||
categories << category
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user