FIX: Make sure the unread counter is updated following a "Dismiss New"

This commit is contained in:
Robin Ward 2014-04-24 15:52:07 -04:00
parent feaaf55a0c
commit f527ac33b0
2 changed files with 10 additions and 4 deletions

View File

@ -81,7 +81,16 @@ Discourse.DiscoveryTopicsController = Discourse.DiscoveryController.extend({
} else { } else {
promise = Discourse.Topic.bulkOperationByFilter(this.get('filter'), operation); promise = Discourse.Topic.bulkOperationByFilter(this.get('filter'), operation);
} }
promise.then(function() { self.send('refresh'); }); promise.then(function(result) {
if (result && result.topic_ids) {
var tracker = Discourse.TopicTrackingState.current();
result.topic_ids.forEach(function(t) {
tracker.removeTopic(t);
});
tracker.incrementMessageCount();
}
self.send('refresh');
});
} }
}, },

View File

@ -5,7 +5,6 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
this._super(); this._super();
this.unreadSequence = []; this.unreadSequence = [];
this.newSequence = []; this.newSequence = [];
this.states = {}; this.states = {};
}, },
@ -13,7 +12,6 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
var tracker = this; var tracker = this;
var process = function(data){ var process = function(data){
if (data.message_type === "delete") { if (data.message_type === "delete") {
tracker.removeTopic(data.topic_id); tracker.removeTopic(data.topic_id);
tracker.incrementMessageCount(); tracker.incrementMessageCount();
@ -28,7 +26,6 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
tracker.incrementMessageCount(); tracker.incrementMessageCount();
} }
} }
}; };
Discourse.MessageBus.subscribe("/new", process); Discourse.MessageBus.subscribe("/new", process);