diff --git a/app/assets/javascripts/discourse/models/user.js b/app/assets/javascripts/discourse/models/user.js
index a41b24d03f0..6baecbced68 100644
--- a/app/assets/javascripts/discourse/models/user.js
+++ b/app/assets/javascripts/discourse/models/user.js
@@ -181,8 +181,9 @@ Discourse.User = Discourse.Model.extend({
'external_links_in_new_tab',
'watch_new_topics',
'enable_quoting');
- data.watched_category_ids = this.get('watchedCategories').map(function(c){ return c.get('id')});
- data.muted_category_ids = this.get('mutedCategories').map(function(c){ return c.get('id')});
+ _.each(['muted','watched','tracked'], function(s){
+ data[s + '_category_ids'] = user.get(s + 'Categories').map(function(c){ return c.get('id')});
+ });
return Discourse.ajax("/users/" + this.get('username_lower'), {
data: data,
@@ -362,6 +363,12 @@ Discourse.User = Discourse.Model.extend({
}));
}.observes("muted_category_ids"),
+ updateTrackedCategories: function() {
+ this.set("trackedCategories", _.map(this.tracked_category_ids, function(id){
+ return Discourse.Category.findById(id);
+ }));
+ }.observes("tracked_category_ids"),
+
updateWatchedCategories: function() {
this.set("watchedCategories", _.map(this.watched_category_ids, function(id){
return Discourse.Category.findById(id);
diff --git a/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars b/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars
index 1c913011bf8..3164c285630 100644
--- a/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars
+++ b/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars
@@ -141,6 +141,11 @@
{{category-group categories=watchedCategories}}
{{i18n user.watched_categories_instructions}}
+
+
+ {{category-group categories=trackedCategories}}
+
{{i18n user.tracked_categories_instructions}}
+
{{category-group categories=mutedCategories}}
diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb
index 56a4af44510..f7f30c17c88 100644
--- a/app/serializers/user_serializer.rb
+++ b/app/serializers/user_serializer.rb
@@ -62,6 +62,7 @@ class UserSerializer < BasicUserSerializer
:gravatar_template,
:uploaded_avatar_template,
:muted_category_ids,
+ :tracked_category_ids,
:watched_category_ids
@@ -112,6 +113,10 @@ class UserSerializer < BasicUserSerializer
CategoryUser.lookup(object, :muted).pluck(:category_id)
end
+ def tracked_category_ids
+ CategoryUser.lookup(object, :tracking).pluck(:category_id)
+ end
+
def watched_category_ids
CategoryUser.lookup(object, :watching).pluck(:category_id)
end
diff --git a/app/services/user_updater.rb b/app/services/user_updater.rb
index 6fbffd03c78..7130c2d199c 100644
--- a/app/services/user_updater.rb
+++ b/app/services/user_updater.rb
@@ -15,6 +15,10 @@ class UserUpdater
CategoryUser.batch_set(user, :watching, ids)
end
+ if ids = attributes[:tracked_category_ids]
+ CategoryUser.batch_set(user, :tracking, ids)
+ end
+
if ids = attributes[:muted_category_ids]
CategoryUser.batch_set(user, :muted, ids)
end
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 8fa64f1c394..68311d912dc 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -230,6 +230,8 @@ en:
watch_new_topics: "Automatically watch all new topics posted on the forum"
watched_categories: "Watched"
watched_categories_instructions: "You will automatically watch all topics in these categories"
+ tracked_categories: "Tracked"
+ tracked_categories_instructions: "You will automatically recieve notifications for topics in these categories"
muted_categories: "Muted"
muted_categories_instructions: "You will automatically mute all topics in these categories"