mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06: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/%@"),
|
adminPath: url('username_lower', "/admin/users/%@"),
|
||||||
|
|
||||||
|
mutedTopicsPath: url('/latest?state=muted'),
|
||||||
|
|
||||||
@computed("username")
|
@computed("username")
|
||||||
username_lower(username) {
|
username_lower(username) {
|
||||||
return username.toLowerCase();
|
return username.toLowerCase();
|
||||||
|
@ -235,6 +235,13 @@
|
|||||||
<div class="instructions">{{i18n 'user.muted_categories_instructions'}}</div>
|
<div class="instructions">{{i18n 'user.muted_categories_instructions'}}</div>
|
||||||
</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">
|
<div class="control-group muting">
|
||||||
<label class="control-label">{{i18n 'user.users'}}</label>
|
<label class="control-label">{{i18n 'user.users'}}</label>
|
||||||
<div class="controls category-controls">
|
<div class="controls category-controls">
|
||||||
|
@ -470,6 +470,7 @@ en:
|
|||||||
users: "Users"
|
users: "Users"
|
||||||
muted_users: "Muted"
|
muted_users: "Muted"
|
||||||
muted_users_instructions: "Suppress all notifications from these users."
|
muted_users_instructions: "Suppress all notifications from these users."
|
||||||
|
muted_topics_link: "Show muted topics"
|
||||||
|
|
||||||
staff_counters:
|
staff_counters:
|
||||||
flags_given: "helpful flags"
|
flags_given: "helpful flags"
|
||||||
|
@ -201,6 +201,7 @@ class TopicQuery
|
|||||||
|
|
||||||
def latest_results(options={})
|
def latest_results(options={})
|
||||||
result = default_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 = remove_muted_categories(result, @user, exclude: options[:category])
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
@ -215,6 +216,7 @@ class TopicQuery
|
|||||||
# TODO does this make sense or should it be ordered on created_at
|
# TODO does this make sense or should it be ordered on created_at
|
||||||
# it is ordering on bumped_at now
|
# 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 = 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])
|
result = remove_muted_categories(result, @user, exclude: options[:category])
|
||||||
suggested_ordering(result, options)
|
suggested_ordering(result, options)
|
||||||
end
|
end
|
||||||
@ -395,6 +397,13 @@ class TopicQuery
|
|||||||
@guardian.filter_allowed_categories(result)
|
@guardian.filter_allowed_categories(result)
|
||||||
end
|
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)
|
def remove_muted_categories(list, user, opts=nil)
|
||||||
category_id = get_category_id(opts[:exclude]) if opts
|
category_id = get_category_id(opts[:exclude]) if opts
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user