Skip to content

A platform for community discussion. Free, open, simple.

DEV: Reduce duplication (#26329)

Daniel Waterworth739a139bcf2c
diff --git a/app/models/category_list.rb b/app/models/category_list.rb
index 5697ce6c4ea..30fa828abbf 100644
--- a/app/models/category_list.rb
+++ b/app/models/category_list.rb
@@ -207,22 +207,7 @@ class CategoryList
@categories.delete_if { |c| to_delete.include?(c) }
end
- allowed_topic_create = Set.new(Category.topic_create_allowed(@guardian).pluck(:id))
-
- parent_ids =
- Category
- .secured(@guardian)
- .where(parent_category_id: categories_with_descendants.map(&:id))
- .pluck("DISTINCT parent_category_id")
- .to_set
-
- categories_with_descendants.each do |category|
- category.notification_level = notification_levels[category.id] || default_notification_level
- category.permission = CategoryGroup.permission_types[:full] if allowed_topic_create.include?(
- category.id,
- )
- category.has_children = parent_ids.include?(category.id)
- end
+ Category.preload_user_fields!(@guardian, categories_with_descendants)
end
def prune_empty