2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

FEATURE: remove muted topics from suggested and latest

This commit is contained in:
Sam Saffron 2015-11-02 09:20:22 +11:00
parent 0d15dbd886
commit 606b10445e
4 changed files with 19 additions and 0 deletions

View file

@ -201,6 +201,7 @@ class TopicQuery
def latest_results(options={})
result = default_results(options)
result = remove_muted_topics(result, @user) unless options && options[:state] = "muted".freeze
result = remove_muted_categories(result, @user, exclude: options[:category])
result
end
@ -215,6 +216,7 @@ class TopicQuery
# TODO does this make sense or should it be ordered on created_at
# it is ordering on bumped_at now
result = TopicQuery.new_filter(default_results(options.reverse_merge(:unordered => true)), @user.treat_as_new_topic_start_date)
result = remove_muted_topics(result, @user)
result = remove_muted_categories(result, @user, exclude: options[:category])
suggested_ordering(result, options)
end
@ -395,6 +397,13 @@ class TopicQuery
@guardian.filter_allowed_categories(result)
end
def remove_muted_topics(list, user)
if user
list = list.where('tu.notification_level <> :muted', muted: TopicUser.notification_levels[:muted])
end
list
end
def remove_muted_categories(list, user, opts=nil)
category_id = get_category_id(opts[:exclude]) if opts