mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 21:12:45 +08:00
never double load the stream.
This commit is contained in:
parent
a1f1849392
commit
363e1010c4
|
@ -17,6 +17,10 @@ Discourse.UserStream = Discourse.Model.extend({
|
|||
}.observes('filter'),
|
||||
|
||||
findItems: function() {
|
||||
var me = this;
|
||||
if(this.get("loading")) { return; }
|
||||
this.set("loading",true);
|
||||
|
||||
var url = Discourse.getURL("/user_actions.json?offset=") + this.get('itemsLoaded') + "&username=" + (this.get('user.username_lower'));
|
||||
if (this.get('filter')) {
|
||||
url += "&filter=" + (this.get('filter'));
|
||||
|
@ -24,6 +28,7 @@ Discourse.UserStream = Discourse.Model.extend({
|
|||
|
||||
var stream = this;
|
||||
return Discourse.ajax(url, {cache: 'false'}).then( function(result) {
|
||||
me.set("loading",false);
|
||||
if (result && result.user_actions) {
|
||||
var copy = Em.A();
|
||||
_.each(result.user_actions,function(action) {
|
||||
|
@ -33,7 +38,7 @@ Discourse.UserStream = Discourse.Model.extend({
|
|||
stream.get('content').pushObjects(copy);
|
||||
stream.set('itemsLoaded', stream.get('itemsLoaded') + result.user_actions.length);
|
||||
}
|
||||
});
|
||||
}, function(){ me.set("loading", false); });
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user