mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-21 01:23:40 +00:00
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:
1 parent
9159fb8696
commit
3e2398bbcc
1 file changed
+11
-2
@@ -146,24 +146,33 @@ function onGroupFilter(value: string): void {
|
|||||||
emit("filter");
|
emit("filter");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Bumped by every open/close: only the latest detail request may land. */
|
||||||
|
let detailRequest = 0;
|
||||||
|
|
||||||
async function openDetail(l: SendRecord): Promise<void> {
|
async function openDetail(l: SendRecord): Promise<void> {
|
||||||
if (l.id == null) return;
|
if (l.id == null) return;
|
||||||
|
const mine = ++detailRequest;
|
||||||
detailOpen.value = true;
|
detailOpen.value = true;
|
||||||
detail.value = null;
|
detail.value = null;
|
||||||
detailError.value = "";
|
detailError.value = "";
|
||||||
detailLoading.value = true;
|
detailLoading.value = true;
|
||||||
try {
|
try {
|
||||||
detail.value = await loadById(l.id);
|
const entry = await loadById(l.id);
|
||||||
|
if (mine === detailRequest) detail.value = entry;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (mine === detailRequest) {
|
||||||
detailError.value = err instanceof Error ? err.message : String(err);
|
detailError.value = err instanceof Error ? err.message : String(err);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
detailLoading.value = false;
|
if (mine === detailRequest) detailLoading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeDetail(): void {
|
function closeDetail(): void {
|
||||||
|
detailRequest++;
|
||||||
detailOpen.value = false;
|
detailOpen.value = false;
|
||||||
detail.value = null;
|
detail.value = null;
|
||||||
|
detailLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDetailOpenChange(open: boolean): void {
|
function onDetailOpenChange(open: boolean): void {
|
||||||
|
|||||||
Reference in new issue
Block a user