don't overwrite status of others with concurrent requests

This commit is contained in:
lilydjwg 2023-10-07 18:38:45 +08:00
parent 210e52af12
commit d29f0fc31c

View File

@ -104,7 +104,10 @@
}
}
let concurrency = 0;
async function do_search(more?: any) {
concurrency += 1;
try {
abort.abort();
abort = new AbortController();
if (!group && !islocal) {
@ -118,7 +121,7 @@
error = "";
our_hash_change = true;
console.log(
`searching ${query} for group ${group}, older than ${more}, from ${sender}`
`searching ${query} for group ${group}, older than ${more}, from ${sender}`,
);
const q = new URLSearchParams();
if (group) {
@ -158,10 +161,15 @@
result = r;
}
} catch (e) {
if (concurrency <= 1) {
error = e;
loading = false;
}
}
our_hash_change = false;
} finally {
concurrency -= 1;
}
}
async function on_group_change() {