Don't show load more button unnecessarily

This commit is contained in:
Toby Zerner 2015-05-26 18:00:41 +09:30
parent 95e5a2d69d
commit b3623449c8

View File

@ -12,6 +12,7 @@ export default class ActivityPage extends UserPage {
this.loading = m.prop(true); this.loading = m.prop(true);
this.moreResults = m.prop(false); this.moreResults = m.prop(false);
this.activity = m.prop([]); this.activity = m.prop([]);
this.loadLimit = 20;
var username = m.route.param('username').toLowerCase(); var username = m.route.param('username').toLowerCase();
var users = app.store.all('users'); var users = app.store.all('users');
@ -46,7 +47,7 @@ export default class ActivityPage extends UserPage {
loadResults(offset) { loadResults(offset) {
return app.store.find('activity', { return app.store.find('activity', {
users: this.user().id(), users: this.user().id(),
page: {offset}, page: {offset, limit: this.loadLimit},
type: this.props.filter type: this.props.filter
}) })
} }
@ -60,7 +61,7 @@ export default class ActivityPage extends UserPage {
parseResults(results, append) { parseResults(results, append) {
this.loading(false); this.loading(false);
[].push.apply(this.activity(), results); [].push.apply(this.activity(), results);
this.moreResults(!!results.length); this.moreResults(results.length >= this.loadLimit);
m.redraw(); m.redraw();
return results; return results;
} }