mirror of
https://github.com/discourse/discourse.git
synced 2025-05-03 02:44:37 +08:00
29 lines
701 B
JavaScript
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);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|