FEATURE: Ability to dismiss new topics in a specific tag (#11968)

* FEATURE: Ability to dismiss new topics in a specific tag

Follow up of https://github.com/discourse/discourse/pull/11927

Using the same mechanism to disable new topics in a tag.

* FIX: respect when category and tag is selected
This commit is contained in:
Krzysztof Kotlarek
2021-02-09 10:39:30 +11:00
committed by GitHub
parent f9de2f9d23
commit 354ec6694a
10 changed files with 168 additions and 20 deletions

View File

@ -898,10 +898,21 @@ class TopicsController < ApplicationController
if params[:include_subcategories] == 'true'
category_ids = category_ids.concat(Category.where(parent_category_id: params[:category_id]).pluck(:id))
end
DismissTopics.new(current_user, Topic.where(category_id: category_ids)).perform!
topic_scope =
if params[:tag_id]
Topic.where(category_id: category_ids).joins(:tags).where(tags: { name: params[:tag_id] })
else
Topic.where(category_id: category_ids)
end
DismissTopics.new(current_user, topic_scope).perform!
category_ids.each do |category_id|
TopicTrackingState.publish_dismiss_new(current_user.id, category_id)
TopicTrackingState.publish_dismiss_new(current_user.id, category_id: category_id, tag_id: params[:tag_id])
end
elsif params[:tag_id].present?
DismissTopics.new(current_user, Topic.joins(:tags).where(tags: { name: params[:tag_id] })).perform!
TopicTrackingState.publish_dismiss_new(current_user.id, tag_id: params[:tag_id])
else
if params[:tracked].to_s == "true"
topics = TopicQuery.tracked_filter(TopicQuery.new(current_user).new_results, current_user.id)