mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
AddPerson search: fix aborting query when the query is altered by user
This commit is contained in:
@@ -199,15 +199,26 @@ export default {
|
||||
return;
|
||||
}
|
||||
if (query === this.search.query) {
|
||||
if (this.currentSearchQueryController !== undefined) {
|
||||
this.currentSearchQueryController.abort()
|
||||
if (this.search.currentSearchQueryController !== null) {
|
||||
this.search.currentSearchQueryController.abort();
|
||||
}
|
||||
this.currentSearchQueryController = new AbortController();
|
||||
searchEntities({ query, options: this.options }, this.currentSearchQueryController)
|
||||
.then(suggested => new Promise((resolve, reject) => {
|
||||
this.loadSuggestions(suggested.results);
|
||||
resolve();
|
||||
}));
|
||||
this.search.currentSearchQueryController = new AbortController();
|
||||
searchEntities({ query, options: this.options }, this.search.currentSearchQueryController.signal)
|
||||
.then(suggested => new Promise((resolve, reject) => {
|
||||
this.loadSuggestions(suggested.results);
|
||||
resolve();
|
||||
}))
|
||||
.catch(error => {
|
||||
if (error instanceof DOMException) {
|
||||
if (error.name === 'AbortError') {
|
||||
console.log('request aborted due to user continue typing');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw error;
|
||||
})
|
||||
;
|
||||
}
|
||||
}.bind(this), query.length > 3 ? 300 : 700);
|
||||
},
|
||||
|
Reference in New Issue
Block a user