BUGFIX: muted categories showing up in new via message bus

This commit is contained in:
Sam 2014-06-18 11:21:40 +10:00
parent 9007d96466
commit fed8f7c6f2
3 changed files with 17 additions and 2 deletions

View File

@ -17,6 +17,13 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
tracker.incrementMessageCount();
}
if (data.message_type === "new_topic"){
var ignored_categories = Discourse.User.currentProp("muted_category_ids");
if(_.include(ignored_categories, data.payload.category_id)){
return;
}
}
if (data.message_type === "new_topic" || data.message_type === "unread" || data.message_type === "read") {
tracker.notify(data);
var old = tracker.states["t" + data.topic_id];

View File

@ -26,7 +26,8 @@ class TopicTrackingState
last_read_post_number: nil,
highest_post_number: 1,
created_at: topic.created_at,
topic_id: topic.id
topic_id: topic.id,
category_id: topic.category_id
}
}

View File

@ -22,7 +22,8 @@ class CurrentUserSerializer < BasicUserSerializer
:should_be_redirected_to_top,
:redirected_to_top_reason,
:disable_jump_reply,
:custom_fields
:custom_fields,
:muted_category_ids
def include_site_flagged_posts_count?
object.staff?
@ -93,4 +94,10 @@ class CurrentUserSerializer < BasicUserSerializer
end
end
def muted_category_ids
@muted_category_ids ||= CategoryUser.where(user_id: object.id,
notification_level: TopicUser.notification_levels[:muted])
.pluck(:category_id)
end
end