DEV: Allow loading topic associations on /categories (#31954)

`/categories` sometimes returns accompanying topics under certain site
settings. The `CategoryList` currently allows preloading for topic
custom fields via `preloaded_topic_custom_fields`, but not for topics
themselves.

This addition is required for
https://github.com/discourse/discourse-solved/pull/342.
This commit is contained in:
Natalie Tay
2025-03-24 17:40:15 +08:00
committed by GitHub
parent ea632d705c
commit af03873d37
4 changed files with 38 additions and 1 deletions

View File

@ -1442,6 +1442,12 @@ class Plugin::Instance
DiscoursePluginRegistry.register_topic_preloader_association(fields, self)
end
# When loading /categories with topics, preload topic associations
# using register_category_list_topics_preloader_associations(:association_name)
def register_category_list_topics_preloader_associations(fields)
DiscoursePluginRegistry.register_category_list_topics_preloader_association(fields, self)
end
private
def setting_category