FIX: remove racing requests for admin users (#15936)

This commit is contained in:
Mark VanLandingham 2022-03-16 08:47:48 -05:00 committed by GitHub
parent 704606e731
commit a0f4c7fe88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 1 deletions

View File

@ -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: {