Handle aborted requests by returning early

This commit is contained in:
2026-05-27 11:51:10 -04:00
parent 96218f872e
commit c3d583177a
+6 -2
View File
@@ -499,7 +499,8 @@
this._titlesSection.hidden = !(titlesRes.suggestions || []).length; this._titlesSection.hidden = !(titlesRes.suggestions || []).length;
if (titlesRes.suggestions?.length) this.show(); if (titlesRes.suggestions?.length) this.show();
} catch (err) { } catch (err) {
if (err.name !== "AbortError") this._titlesSection.hidden = true; if (err.name === "AbortError") return; // new request superseded this one
this._titlesSection.hidden = true;
} }
try { try {
const tagsRes = await api(`/api/tags/suggest?q=${encodeURIComponent(prefix)}&vault=${encodeURIComponent(vault)}&limit=5`, { signal: suggestAbortController.signal }); const tagsRes = await api(`/api/tags/suggest?q=${encodeURIComponent(prefix)}&vault=${encodeURIComponent(vault)}&limit=5`, { signal: suggestAbortController.signal });
@@ -507,10 +508,13 @@
this._tagsSection.hidden = !(tagsRes.suggestions || []).length; this._tagsSection.hidden = !(tagsRes.suggestions || []).length;
if (tagsRes.suggestions?.length) this.show(); if (tagsRes.suggestions?.length) this.show();
} catch (err) { } catch (err) {
if (err.name !== "AbortError") this._tagsSection.hidden = true; if (err.name === "AbortError") return;
this._tagsSection.hidden = true;
} }
this._collectItems(); this._collectItems();
}, },
this._collectItems();
},
_renderHistory(items, query) { _renderHistory(items, query) {
this._historyList.innerHTML = ""; this._historyList.innerHTML = "";