DEV: Use a single registry for preloaded category custom fields (#24272)

There was a registry for preloaded site categories and a new one has
been introduced recently for categories serialized through a
CategoryList.

Having two registries created a lot of friction for developers and this
commit merges them into a single one, providing a unified API.
This commit is contained in:
Bianca Nenciu
2023-11-09 18:23:24 +02:00
committed by GitHub
parent e772bb9fce
commit bdb81b5346
3 changed files with 7 additions and 10 deletions

View File

@@ -6,9 +6,6 @@ class CategoryList
cattr_accessor :preloaded_topic_custom_fields
self.preloaded_topic_custom_fields = Set.new
cattr_accessor :preloaded_category_custom_fields
self.preloaded_category_custom_fields = Set.new
attr_accessor :categories, :uncategorized
def self.register_included_association(association)
@@ -142,8 +139,8 @@ class CategoryList
@categories = query.to_a
if preloaded_category_custom_fields.any?
Category.preload_custom_fields(@categories, preloaded_category_custom_fields)
if Site.preloaded_category_custom_fields.any?
Category.preload_custom_fields(@categories, Site.preloaded_category_custom_fields)
end
include_subcategories = @options[:include_subcategories] == true