mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 10:59:51 +08:00
FIX: Make sure user list is complete and sorted (#17616)
Sometimes the user list was incomplete when multiple requests were
created to fetch next pages. If the responses did not arrive in the
same order as the requests then only the last response was parsed.
This is a follow up commit to a0f4c7fe88
.
This commit is contained in:
parent
47917c0be4
commit
171789f47a
|
@ -17,7 +17,6 @@ export default Controller.extend(CanCheckEmails, {
|
|||
listFilter: null,
|
||||
selectAll: false,
|
||||
searchHint: i18n("search_hint"),
|
||||
_searchIndex: 0,
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
@ -49,8 +48,7 @@ export default Controller.extend(CanCheckEmails, {
|
|||
return;
|
||||
}
|
||||
|
||||
this._searchIndex++;
|
||||
const searchIndex = this._searchIndex;
|
||||
const page = this._page;
|
||||
this.set("refreshing", true);
|
||||
|
||||
AdminUser.findAll(this.query, {
|
||||
|
@ -58,34 +56,21 @@ export default Controller.extend(CanCheckEmails, {
|
|||
show_emails: this.showEmails,
|
||||
order: this.order,
|
||||
asc: this.asc,
|
||||
page: this._page,
|
||||
page,
|
||||
})
|
||||
.then((result) => {
|
||||
if (this.ignoreResponse(searchIndex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!result || result.length === 0) {
|
||||
if (result && result.length > 0) {
|
||||
this._results[page] = result;
|
||||
this.set("model", this._results.flat());
|
||||
} else {
|
||||
this._canLoadMore = false;
|
||||
}
|
||||
|
||||
this._results = this._results.concat(result);
|
||||
this.set("model", this._results);
|
||||
})
|
||||
.finally(() => {
|
||||
if (this.ignoreResponse(searchIndex)) {
|
||||
return;
|
||||
}
|
||||
this.set("refreshing", false);
|
||||
});
|
||||
},
|
||||
|
||||
ignoreResponse(searchIndex) {
|
||||
return (
|
||||
searchIndex !== this._searchIndex || this.isDestroyed || this.isDestroying
|
||||
);
|
||||
},
|
||||
|
||||
actions: {
|
||||
loadMore() {
|
||||
this._page += 1;
|
||||
|
|
Loading…
Reference in New Issue
Block a user