mirror of
https://github.com/discourse/discourse.git
synced 2025-02-22 12:17:12 +00:00
Fix infinate loading of group posts (#5296)
This commit is contained in:
parent
fc7dca58fe
commit
8a8c14c6f7
@ -1,13 +1,17 @@
|
||||
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
||||
import { fmt } from 'discourse/lib/computed';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
group: Ember.inject.controller(),
|
||||
groupActivity: Ember.inject.controller(),
|
||||
application: Ember.inject.controller(),
|
||||
canLoadMore: true,
|
||||
loading: false,
|
||||
emptyText: fmt('type', 'groups.empty.%@'),
|
||||
|
||||
actions: {
|
||||
loadMore() {
|
||||
if (!this.get('canLoadMore')) { return; }
|
||||
if (this.get('loading')) { return; }
|
||||
this.set('loading', true);
|
||||
const posts = this.get('model');
|
||||
@ -20,9 +24,18 @@ export default Ember.Controller.extend({
|
||||
|
||||
group.findPosts(opts).then(newPosts => {
|
||||
posts.addObjects(newPosts);
|
||||
if(newPosts.length === 0) {
|
||||
this.set('canLoadMore', false);
|
||||
}
|
||||
}).finally(() => {
|
||||
this.set('loading', false);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@observes('canLoadMore')
|
||||
_showFooter() {
|
||||
this.set("application.showFooter", !this.get("canLoadMore"));
|
||||
}
|
||||
});
|
||||
|
@ -12,7 +12,7 @@ export function buildGroupPage(type) {
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
this.controllerFor('group-activity-posts').setProperties({ model, type });
|
||||
this.controllerFor('group-activity-posts').setProperties({ model, type, canLoadMore: true });
|
||||
this.controllerFor("group").set("showing", type);
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user