mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Can't dismiss new topics that belong to a sub-sub category (#22849)
What is the context for this change? Prior to this change, there is a bug in `TopicsController#reset_new` where it does not dismiss new topics in sub-subcategories when the `category_id` and `include_subcategories=true` params are present. This is because the controller did not account for sub-subcategories when fetching the category ids of the new topics that should be dismissed. This commit fixes the problem by relying on the `Category.subcategory_ids` class method which accounts for sub-subcategories.
This commit is contained in:
committed by
GitHub
parent
26fc5d2d1f
commit
32d4810e2b
@@ -1062,13 +1062,17 @@ class TopicsController < ApplicationController
|
||||
if tag_name = params[:tag_id]
|
||||
tag_name = DiscourseTagging.visible_tags(guardian).where(name: tag_name).pluck(:name).first
|
||||
end
|
||||
|
||||
topic_scope =
|
||||
if params[:category_id].present?
|
||||
category_ids = [params[:category_id].to_i]
|
||||
if ActiveModel::Type::Boolean.new.cast(params[:include_subcategories])
|
||||
category_ids =
|
||||
category_ids.concat(Category.where(parent_category_id: params[:category_id]).pluck(:id))
|
||||
end
|
||||
category_id = params[:category_id].to_i
|
||||
|
||||
category_ids =
|
||||
if ActiveModel::Type::Boolean.new.cast(params[:include_subcategories])
|
||||
Category.subcategory_ids(category_id)
|
||||
else
|
||||
[category_id]
|
||||
end
|
||||
|
||||
category_ids &= guardian.allowed_category_ids
|
||||
if category_ids.blank?
|
||||
|
||||
Reference in New Issue
Block a user