when autocompleting, abort previous still pending request

should prevent a long list of "Autocompleting address" mentions in the status
bar at the top in case of non-responsive network
This commit is contained in:
Mechiel Lukkien
2023-12-14 14:31:06 +01:00
parent 22f46aa174
commit 406fdc312d
2 changed files with 18 additions and 2 deletions

View File

@ -1609,6 +1609,7 @@ const newAddressComplete = () => {
let completeMatches;
let completeSearch;
let completeFull;
let aborter = {};
return async function keydown(e) {
const target = e.target;
if (!datalist) {
@ -1634,14 +1635,21 @@ const newAddressComplete = () => {
else if (search === completeSearch) {
return;
}
if (aborter.abort) {
aborter.abort();
}
aborter = {};
try {
[completeMatches, completeFull] = await withStatus('Autocompleting addresses', client.CompleteRecipient(search));
[completeMatches, completeFull] = await withStatus('Autocompleting addresses', client.withOptions({ aborter: aborter }).CompleteRecipient(search));
completeSearch = search;
dom._kids(datalist, (completeMatches || []).map(s => dom.option(s)));
}
catch (err) {
log('autocomplete error', errmsg(err));
}
finally {
aborter = {};
}
};
};
const flagList = (miv) => {