This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/group/index.js.es6

29 lines
701 B
JavaScript

/**
Handles displaying posts within a group
**/
export default Ember.ArrayController.extend({
needs: ['group'],
loading: false,
actions: {
loadMore: function() {
if (this.get('loading')) { return; }
this.set('loading', true);
var posts = this.get('model'),
self = this;
if (posts && posts.length) {
var lastPostId = posts[posts.length-1].get('id'),
group = this.get('controllers.group.model');
var opts = {beforePostId: lastPostId, type: this.get('type')};
group.findPosts(opts).then(function(newPosts) {
posts.addObjects(newPosts);
self.set('loading', false);
});
}
}
}
});