mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:21:18 +08:00
FIX: Respect show_category_definitions_in_topic_lists in category lists (#10853)
When that site setting is enabled, the category counts (new/unread) include the subcategory definition topics, but the topics aren't included in the list. This fixes that discrepancy.
This commit is contained in:
@ -700,11 +700,10 @@ class TopicQuery
|
||||
if options[:no_subcategories]
|
||||
result = result.where('categories.id = ?', category_id)
|
||||
else
|
||||
result = result.where(<<~SQL, subcategory_ids: Category.subcategory_ids(category_id), category_id: category_id)
|
||||
categories.id in (:subcategory_ids) AND (
|
||||
categories.topic_id <> topics.id OR categories.id = :category_id
|
||||
)
|
||||
SQL
|
||||
result = result.where("categories.id IN (?)", Category.subcategory_ids(category_id))
|
||||
if !SiteSetting.show_category_definitions_in_topic_lists
|
||||
result = result.where("categories.topic_id <> topics.id OR categories.id = ?", category_id)
|
||||
end
|
||||
end
|
||||
result = result.references(:categories)
|
||||
|
||||
|
Reference in New Issue
Block a user