Fix discussion list pagination

This commit is contained in:
Toby Zerner 2015-05-07 08:58:04 +09:30
parent 0a5f6ac94d
commit db80a36729
2 changed files with 5 additions and 6 deletions

View File

@ -60,23 +60,23 @@ export default class DiscussionList extends Component {
return this.props.params.sort === 'replies' ? 'replies' : 'unread';
}
loadResults(start) {
loadResults(offset) {
var params = this.params();
params.start = start;
params.page = {offset};
return app.store.find('discussions', params);
}
loadMore() {
var self = this;
this.loading(true);
this.loadResults(this.discussions().length).then((results) => this.parseResults(results, true));
this.loadResults(this.discussions().length).then((results) => this.parseResults(results));
}
parseResults(results, append) {
parseResults(results) {
m.startComputation();
this.loading(false);
[].push.apply(this.discussions(), results);
this.moreResults(!!results.meta.moreUrl);
this.moreResults(!!results.payload.links.next);
m.endComputation();
return results;
}

View File

@ -7,7 +7,6 @@ export default class Store {
pushPayload(payload) {
payload.included && payload.included.map(this.pushObject.bind(this))
var result = payload.data instanceof Array ? payload.data.map(this.pushObject.bind(this)) : this.pushObject(payload.data);
result.meta = payload.meta;
result.payload = payload;
return result;
}