mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
FIX: Stop endless loading at the bottom of a user's stream.
This commit is contained in:
parent
d9e5c2317f
commit
bddd7f5ea3
@ -65,16 +65,19 @@ Discourse.UserStream = Discourse.Model.extend({
|
||||
},
|
||||
|
||||
findItems: function() {
|
||||
var userStream = this;
|
||||
if(this.get('loading')) { return Ember.RSVP.reject(); }
|
||||
|
||||
this.set('loading', true);
|
||||
var self = this;
|
||||
|
||||
var url = this.get('baseUrl');
|
||||
if (this.get('filterParam')) {
|
||||
url += "&filter=" + this.get('filterParam');
|
||||
}
|
||||
|
||||
// Don't load the same stream twice. We're probably at the end.
|
||||
var lastLoadedUrl = this.get('lastLoadedUrl');
|
||||
if (lastLoadedUrl === url) { return Ember.RSVP.resolve(); }
|
||||
|
||||
if (this.get('loading')) { return Ember.RSVP.resolve(); }
|
||||
this.set('loading', true);
|
||||
return Discourse.ajax(url, {cache: 'false'}).then( function(result) {
|
||||
if (result && result.user_actions) {
|
||||
var copy = Em.A();
|
||||
@ -82,14 +85,15 @@ Discourse.UserStream = Discourse.Model.extend({
|
||||
copy.pushObject(Discourse.UserAction.create(action));
|
||||
});
|
||||
|
||||
userStream.get('content').pushObjects(Discourse.UserAction.collapseStream(copy));
|
||||
userStream.setProperties({
|
||||
self.get('content').pushObjects(Discourse.UserAction.collapseStream(copy));
|
||||
self.setProperties({
|
||||
loaded: true,
|
||||
itemsLoaded: userStream.get('itemsLoaded') + result.user_actions.length
|
||||
itemsLoaded: self.get('itemsLoaded') + result.user_actions.length
|
||||
});
|
||||
}
|
||||
}).finally(function() {
|
||||
userStream.set('loading', false);
|
||||
self.set('loading', false);
|
||||
self.set('lastLoadedUrl', url);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,6 @@ export default Ember.View.extend(Discourse.LoadMore, {
|
||||
stream.findItems().then(function() {
|
||||
self.set('loading', false);
|
||||
self.get('eyeline').flushRest();
|
||||
}).catch(function() {
|
||||
// If we were already loading...
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user