fix(console): discard stale log detail responses

An older detail request can finish after a newer selection or close.
Discard it so the dialog never shows the previously clicked record.
This commit is contained in:
翅膀 committed 2026-10-23 23:23:51 +08:00
1 parent 9159fb8696
commit 3e2398bbcc
1 file changed
+12 -3
+12 -3
View File
@@ -146,24 +146,33 @@ function onGroupFilter(value: string): void {
emit("filter");
}
/** Bumped by every open/close: only the latest detail request may land. */
let detailRequest = 0;
async function openDetail(l: SendRecord): Promise<void> {
if (l.id == null) return;
const mine = ++detailRequest;
detailOpen.value = true;
detail.value = null;
detailError.value = "";
detailLoading.value = true;
try {
detail.value = await loadById(l.id);
const entry = await loadById(l.id);
if (mine === detailRequest) detail.value = entry;
} catch (err) {
detailError.value = err instanceof Error ? err.message : String(err);
if (mine === detailRequest) {
detailError.value = err instanceof Error ? err.message : String(err);
}
} finally {
detailLoading.value = false;
if (mine === detailRequest) detailLoading.value = false;
}
}
function closeDetail(): void {
detailRequest++;
detailOpen.value = false;
detail.value = null;
detailLoading.value = false;
}
function onDetailOpenChange(open: boolean): void {