mirror of
https://github.com/flarum/framework.git
synced 2024-12-03 15:43:59 +08:00
Fix discussion list pagination
This commit is contained in:
parent
0a5f6ac94d
commit
db80a36729
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user