mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 12:42:16 +08:00
FEATURE: remove muted topics from suggested and latest
This commit is contained in:
parent
0d15dbd886
commit
606b10445e
|
@ -68,6 +68,8 @@ const User = RestModel.extend({
|
|||
|
||||
adminPath: url('username_lower', "/admin/users/%@"),
|
||||
|
||||
mutedTopicsPath: url('/latest?state=muted'),
|
||||
|
||||
@computed("username")
|
||||
username_lower(username) {
|
||||
return username.toLowerCase();
|
||||
|
|
|
@ -235,6 +235,13 @@
|
|||
<div class="instructions">{{i18n 'user.muted_categories_instructions'}}</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group topics">
|
||||
<label class="control-label">{{i18n 'categories.topics'}}</label>
|
||||
<div class="controls topic-controls">
|
||||
<a href="{{unbound model.mutedTopicsPath}}">{{i18n 'user.muted_topics_link'}}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group muting">
|
||||
<label class="control-label">{{i18n 'user.users'}}</label>
|
||||
<div class="controls category-controls">
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user