fix topic counts not updating automatically in various spots (top menu / categories page / drop down)
This commit is contained in:
parent
92528d7207
commit
6544f39bcc
|
@ -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')
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
{{#if currentUser}}
|
||||
{{#with view.category}}
|
||||
{{#if unreadTopics}}
|
||||
<a href={{unbound unreadUrl}} class='badge unread-posts badge-notification' title='{{i18n topic.unread_topics count="unreadTopics"}}'>{{unbound unreadTopics}}</a>
|
||||
<a href={{unbound unreadUrl}} class='badge unread-posts badge-notification' title='{{i18n topic.unread_topics count="unreadTopics"}}'>{{unreadTopics}}</a>
|
||||
{{/if}}
|
||||
{{#if newTopics}}
|
||||
<a href={{unbound newUrl}} class='badge new-posts badge-notification' title='{{i18n topic.new_topics count="newTopics"}}'>{{unbound newTopics}} <i class='icon icon-asterisk'></i></a>
|
||||
<a href={{unbound newUrl}} class='badge new-posts badge-notification' title='{{i18n topic.new_topics count="newTopics"}}'>{{newTopics}} <i class='icon icon-asterisk'></i></a>
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
{{else}}
|
||||
|
|
|
@ -54,10 +54,10 @@
|
|||
{{topicStatus topic=this}}
|
||||
<a class='title' href="{{unbound lastUnreadUrl}}">{{{unbound fancy_title}}}</a>
|
||||
{{#if unread}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts count="unread"}}'>{{unbound unread}}</a>
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts count="unread"}}'>{{unread}}</a>
|
||||
{{/if}}
|
||||
{{#if new_posts}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts count="new_posts"}}'>{{unbound new_posts}}</a>
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts count="new_posts"}}'>{{new_posts}}</a>
|
||||
{{/if}}
|
||||
{{#if unseen}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue