mirror of
https://github.com/discourse/discourse.git
synced 2025-03-06 03:09:43 +00:00
FIX: remove racing requests for admin users (#15936)
This commit is contained in:
parent
704606e731
commit
a0f4c7fe88
@ -17,6 +17,7 @@ export default Controller.extend(CanCheckEmails, {
|
||||
listFilter: null,
|
||||
selectAll: false,
|
||||
searchHint: i18n("search_hint"),
|
||||
_searchIndex: 0,
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
@ -48,6 +49,8 @@ export default Controller.extend(CanCheckEmails, {
|
||||
return;
|
||||
}
|
||||
|
||||
this._searchIndex++;
|
||||
const searchIndex = this._searchIndex;
|
||||
this.set("refreshing", true);
|
||||
|
||||
AdminUser.findAll(this.query, {
|
||||
@ -58,6 +61,10 @@ export default Controller.extend(CanCheckEmails, {
|
||||
page: this._page,
|
||||
})
|
||||
.then((result) => {
|
||||
if (this.ignoreResponse(searchIndex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!result || result.length === 0) {
|
||||
this._canLoadMore = false;
|
||||
}
|
||||
@ -65,7 +72,18 @@ export default Controller.extend(CanCheckEmails, {
|
||||
this._results = this._results.concat(result);
|
||||
this.set("model", this._results);
|
||||
})
|
||||
.finally(() => this.set("refreshing", false));
|
||||
.finally(() => {
|
||||
if (this.ignoreResponse(searchIndex)) {
|
||||
return;
|
||||
}
|
||||
this.set("refreshing", false);
|
||||
});
|
||||
},
|
||||
|
||||
ignoreResponse(searchIndex) {
|
||||
return (
|
||||
searchIndex !== this._searchIndex || this.isDestroyed || this.isDestroying
|
||||
);
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user