This repository has been archived on 2023-03-18. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
osr-discourse-src/app/assets/javascripts/discourse/controllers/group_index_controller.js
T
2014-02-07 10:44:51 -05:00

33 lines
777 B
JavaScript

/**
Handles displaying posts within a group
@class GroupIndexController
@extends Ember.ArrayController
@namespace Discourse
@module Discourse
**/
Discourse.GroupIndexController = 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');
group.findPosts({beforePostId: lastPostId}).then(function(newPosts) {
posts.addObjects(newPosts);
self.set('loading', false);
});
}
}
}
});