mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FEATURE: Dismiss new per category (#8330)
Ability to dismiss new topics per category.
This commit is contained in:

committed by
GitHub

parent
d095c2cee7
commit
6e1fe22a9d
@ -847,7 +847,23 @@ class TopicsController < ApplicationController
|
||||
end
|
||||
|
||||
def reset_new
|
||||
current_user.user_stat.update_column(:new_since, Time.now)
|
||||
if params[:category_id].present?
|
||||
category_ids = [params[:category_id]]
|
||||
|
||||
if params[:include_subcategories] == 'true'
|
||||
category_ids = category_ids.concat(Category.where(parent_category_id: params[:category_id]).pluck(:id))
|
||||
end
|
||||
|
||||
category_ids.each do |category_id|
|
||||
current_user
|
||||
.category_users
|
||||
.where(category_id: category_id)
|
||||
.first_or_initialize
|
||||
.update!(last_seen_at: Time.zone.now)
|
||||
end
|
||||
else
|
||||
current_user.user_stat.update_column(:new_since, Time.now)
|
||||
end
|
||||
render body: nil
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user