FIX: streaming incorrect events into all tab

This commit is contained in:
Sam 2014-10-08 13:35:07 +11:00
parent 67429b29a5
commit b9a9fb54da
1 changed files with 11 additions and 2 deletions

View File

@ -258,7 +258,10 @@ Discourse.User = Discourse.Model.extend({
return Discourse.ajax("/user_actions/" + id + ".json", { cache: 'false' }).then(function(result) {
if (result && result.user_action) {
var ua = result.user_action;
if ((self.get('stream.filter') || ua.action_type) !== ua.action_type) return;
if (!self.get('stream.filter') && !self.inAllStream(ua)) return;
var action = Discourse.UserAction.collapseStream([Discourse.UserAction.create(ua)]);
stream.set('itemsLoaded', stream.get('itemsLoaded') + 1);
stream.get('content').insertAt(0, action[0]);
@ -266,6 +269,11 @@ Discourse.User = Discourse.Model.extend({
});
},
inAllStream: function(ua) {
return ua.action_type === Discourse.UserAction.TYPES.posts ||
ua.action_type === Discourse.UserAction.TYPES.topics;
},
/**
The user's stat count, excluding PMs.
@ -273,11 +281,12 @@ Discourse.User = Discourse.Model.extend({
@type {Integer}
**/
statsCountNonPM: function() {
var self = this;
if (this.blank('statsExcludingPms')) return 0;
var count = 0;
_.each(this.get('statsExcludingPms'), function(val) {
if (val.action_type === Discourse.UserAction.TYPES.posts ||
val.action_type === Discourse.UserAction.TYPES.topics ) {
if (self.inAllStream(val)){
count += val.count;
}
});