diff --git a/app/assets/javascripts/discourse/models/category.js b/app/assets/javascripts/discourse/models/category.js
index 015b50f31f0..7c68c9950b0 100644
--- a/app/assets/javascripts/discourse/models/category.js
+++ b/app/assets/javascripts/discourse/models/category.js
@@ -114,13 +114,17 @@ Discourse.Category = Discourse.Model.extend({
return this.get("topics")[0];
}.property("topics"),
+ topicTrackingState: function(){
+ return Discourse.TopicTrackingState.current();
+ }.property(),
+
unreadTopics: function(){
- return Discourse.TopicTrackingState.current().countUnread(this.get('name'));
- }.property('Discourse.TopicTrackingState.current.messageCount'),
+ return this.get('topicTrackingState').countUnread(this.get('name'));
+ }.property('topicTrackingState.messageCount'),
newTopics: function(){
- return Discourse.TopicTrackingState.current().countNew(this.get('name'));
- }.property('Discourse.TopicTrackingState.current.messageCount')
+ return this.get('topicTrackingState').countNew(this.get('name'));
+ }.property('topicTrackingState.messageCount')
});
diff --git a/app/assets/javascripts/discourse/models/topic_tracking_state.js b/app/assets/javascripts/discourse/models/topic_tracking_state.js
index 90584c7839a..c19de09a764 100644
--- a/app/assets/javascripts/discourse/models/topic_tracking_state.js
+++ b/app/assets/javascripts/discourse/models/topic_tracking_state.js
@@ -13,16 +13,22 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
var tracker = this;
var process = function(data){
+
if (data.message_type === "delete") {
tracker.removeTopic(data.topic_id);
+ tracker.incrementMessageCount();
}
if (data.message_type === "new_topic" || data.message_type === "unread" || data.message_type === "read") {
tracker.notify(data);
- tracker.states["t" + data.topic_id] = data.payload;
+ var old = tracker.states["t" + data.topic_id];
+
+ if(!_.isEqual(old, data.payload)){
+ tracker.states["t" + data.topic_id] = data.payload;
+ tracker.incrementMessageCount();
+ }
}
- tracker.incrementMessageCount();
};
Discourse.MessageBus.subscribe("/new", process);
diff --git a/app/assets/javascripts/discourse/templates/components/header-category-info.js.handlebars b/app/assets/javascripts/discourse/templates/components/header-category-info.js.handlebars
index d21be9154c3..feec6de8f90 100644
--- a/app/assets/javascripts/discourse/templates/components/header-category-info.js.handlebars
+++ b/app/assets/javascripts/discourse/templates/components/header-category-info.js.handlebars
@@ -2,10 +2,10 @@
{{#if currentUser}}
{{#with view.category}}
{{#if unreadTopics}}
- {{unbound unreadTopics}}
+ {{unreadTopics}}
{{/if}}
{{#if newTopics}}
- {{unbound newTopics}}
+ {{newTopics}}
{{/if}}
{{/with}}
{{else}}
diff --git a/app/assets/javascripts/discourse/templates/list/wide_categories.js.handlebars b/app/assets/javascripts/discourse/templates/list/wide_categories.js.handlebars
index 01169551a9e..4c82e1d1f3b 100644
--- a/app/assets/javascripts/discourse/templates/list/wide_categories.js.handlebars
+++ b/app/assets/javascripts/discourse/templates/list/wide_categories.js.handlebars
@@ -54,10 +54,10 @@
{{topicStatus topic=this}}
{{{unbound fancy_title}}}
{{#if unread}}
- {{unbound unread}}
+ {{unread}}
{{/if}}
{{#if new_posts}}
- {{unbound new_posts}}
+ {{new_posts}}
{{/if}}
{{#if unseen}}
diff --git a/app/assets/javascripts/discourse/views/nav_item_view.js b/app/assets/javascripts/discourse/views/nav_item_view.js
index 143d3475ac4..8050ac888ac 100644
--- a/app/assets/javascripts/discourse/views/nav_item_view.js
+++ b/app/assets/javascripts/discourse/views/nav_item_view.js
@@ -12,8 +12,7 @@ Discourse.NavItemView = Discourse.View.extend({
attributeBindings: ['title'],
hidden: Em.computed.not('content.visible'),
- count: Ember.computed.alias('content.count'),
- shouldRerender: Discourse.View.renderIfChanged('count'),
+ shouldRerender: Discourse.View.renderIfChanged('content.count'),
active: Discourse.computed.propertyEqual('content.filterMode', 'controller.filterMode'),
title: function() {
@@ -41,7 +40,7 @@ Discourse.NavItemView = Discourse.View.extend({
extra.categoryName = Discourse.Formatter.toTitleCase(categoryName);
}
return I18n.t("filters." + name + ".title", extra);
- }.property('count'),
+ }.property('content.count'),
render: function(buffer) {
var content = this.get('content');
diff --git a/app/models/topic_tracking_state.rb b/app/models/topic_tracking_state.rb
index 507f3bc2553..c8386b802b0 100644
--- a/app/models/topic_tracking_state.rb
+++ b/app/models/topic_tracking_state.rb
@@ -53,25 +53,26 @@ class TopicTrackingState
}
MessageBus.publish("/unread/#{tu.user_id}", message.as_json, group_ids: group_ids)
-
end
+
end
def self.publish_read(topic_id, last_read_post_number, user_id)
- highest_post_number = Topic.where(id: topic_id).pluck(:highest_post_number).first
+ highest_post_number = Topic.where(id: topic_id).pluck(:highest_post_number).first
- message = {
- topic_id: topic_id,
- message_type: "read",
- payload: {
- last_read_post_number: last_read_post_number,
- highest_post_number: highest_post_number,
- topic_id: topic_id
- }
+ message = {
+ topic_id: topic_id,
+ message_type: "read",
+ payload: {
+ last_read_post_number: last_read_post_number,
+ highest_post_number: highest_post_number,
+ topic_id: topic_id
}
+ }
+
+ MessageBus.publish("/unread/#{user_id}", message.as_json, user_ids: [user_id])
- MessageBus.publish("/unread/#{user_id}", message.as_json, user_ids: [user_id])
end
def self.treat_as_new_topic_clause