mirror of
https://github.com/mjl-/mox.git
synced 2025-07-13 12:14:37 +03:00
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:
@ -1609,6 +1609,7 @@ const newAddressComplete = () => {
|
|||||||
let completeMatches;
|
let completeMatches;
|
||||||
let completeSearch;
|
let completeSearch;
|
||||||
let completeFull;
|
let completeFull;
|
||||||
|
let aborter = {};
|
||||||
return async function keydown(e) {
|
return async function keydown(e) {
|
||||||
const target = e.target;
|
const target = e.target;
|
||||||
if (!datalist) {
|
if (!datalist) {
|
||||||
@ -1634,14 +1635,21 @@ const newAddressComplete = () => {
|
|||||||
else if (search === completeSearch) {
|
else if (search === completeSearch) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (aborter.abort) {
|
||||||
|
aborter.abort();
|
||||||
|
}
|
||||||
|
aborter = {};
|
||||||
try {
|
try {
|
||||||
[completeMatches, completeFull] = await withStatus('Autocompleting addresses', client.CompleteRecipient(search));
|
[completeMatches, completeFull] = await withStatus('Autocompleting addresses', client.withOptions({ aborter: aborter }).CompleteRecipient(search));
|
||||||
completeSearch = search;
|
completeSearch = search;
|
||||||
dom._kids(datalist, (completeMatches || []).map(s => dom.option(s)));
|
dom._kids(datalist, (completeMatches || []).map(s => dom.option(s)));
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
log('autocomplete error', errmsg(err));
|
log('autocomplete error', errmsg(err));
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
aborter = {};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
const flagList = (miv) => {
|
const flagList = (miv) => {
|
||||||
|
@ -577,6 +577,8 @@ const newAddressComplete = (): any => {
|
|||||||
let completeSearch: string
|
let completeSearch: string
|
||||||
let completeFull: boolean
|
let completeFull: boolean
|
||||||
|
|
||||||
|
let aborter: {abort?: () => void} = {}
|
||||||
|
|
||||||
return async function keydown(e: KeyboardEvent) {
|
return async function keydown(e: KeyboardEvent) {
|
||||||
const target = e.target as HTMLInputElement
|
const target = e.target as HTMLInputElement
|
||||||
if (!datalist) {
|
if (!datalist) {
|
||||||
@ -603,12 +605,18 @@ const newAddressComplete = (): any => {
|
|||||||
} else if (search === completeSearch) {
|
} else if (search === completeSearch) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (aborter.abort) {
|
||||||
|
aborter.abort()
|
||||||
|
}
|
||||||
|
aborter = {}
|
||||||
try {
|
try {
|
||||||
[completeMatches, completeFull] = await withStatus('Autocompleting addresses', client.CompleteRecipient(search))
|
[completeMatches, completeFull] = await withStatus('Autocompleting addresses', client.withOptions({aborter: aborter}).CompleteRecipient(search))
|
||||||
completeSearch = search
|
completeSearch = search
|
||||||
dom._kids(datalist, (completeMatches || []).map(s => dom.option(s)))
|
dom._kids(datalist, (completeMatches || []).map(s => dom.option(s)))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log('autocomplete error', errmsg(err))
|
log('autocomplete error', errmsg(err))
|
||||||
|
} finally {
|
||||||
|
aborter = {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user