diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index f48dd255bba..5da7dae0337 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -470,6 +470,7 @@ en:
users: "Users"
muted_users: "Muted"
muted_users_instructions: "Suppress all notifications from these users."
+ muted_topics_link: "Show muted topics"
staff_counters:
flags_given: "helpful flags"
diff --git a/lib/topic_query.rb b/lib/topic_query.rb
index 7637bbaa7be..ed23df55672 100644
--- a/lib/topic_query.rb
+++ b/lib/topic_query.rb
@@ -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