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) { async function do_search(more?: any) {
concurrency += 1;
try {
abort.abort(); abort.abort();
abort = new AbortController(); abort = new AbortController();
if (!group && !islocal) { if (!group && !islocal) {
@ -118,7 +121,7 @@
error = ""; error = "";
our_hash_change = true; our_hash_change = true;
console.log( 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(); const q = new URLSearchParams();
if (group) { if (group) {
@ -158,10 +161,15 @@
result = r; result = r;
} }
} catch (e) { } catch (e) {
if (concurrency <= 1) {
error = e; error = e;
loading = false; loading = false;
} }
}
our_hash_change = false; our_hash_change = false;
} finally {
concurrency -= 1;
}
} }
async function on_group_change() { async function on_group_change() {