Poll scrape progress and show page totals

This commit is contained in:
Fisto
2026-09-16 13:52:17 +02:00
parent 5645f55356
commit 2309393e3c
3 changed files with 23 additions and 3 deletions
+15 -2
View File
@@ -176,7 +176,6 @@
setStatus(`media status failed: ${error.message}`);
}
renderScrapes();
if (state.view === "media") renderToolbar();
}
function filterQuery() {
@@ -292,11 +291,20 @@
row.append(el("span", "vk-media-pulse"));
}
// Discord search gives the total, so the page count is known up front.
const estimatedPages =
scrape.estimatedMessages != null ? Math.max(1, Math.ceil(scrape.estimatedMessages / 100)) : null;
const pageText = estimatedPages ? `${scrape.pages}/${estimatedPages}p` : `${scrape.pages}p`;
const percent =
estimatedPages && scrape.state !== "queued"
? ` (~${Math.min(100, Math.round((scrape.pages / estimatedPages) * 100))}%)`
: "";
row.append(
el(
"span",
null,
`${channelLabel(scrape.channelId)} · ${scrape.state} · ${scrape.pages}p · ${scrape.messages}m · ` +
`${channelLabel(scrape.channelId)} · ${scrape.state} · ${pageText}${percent} · ${scrape.messages}m · ` +
`img ${media.image ?? 0} gif ${media.gif ?? 0} vid ${media.video ?? 0} aud ${media.audio ?? 0}` +
(scrape.downloaded ? ` · files ${scrape.downloaded}` : "") +
(scrape.previewed ? ` · previews ${scrape.previewed}` : "")
@@ -754,6 +762,11 @@
if (state.view !== "bot") void refreshErrors();
}, 15000);
// Keep the running-scrape strip live while the media view is open.
setInterval(() => {
if (state.view === "media") void loadScrapes();
}, 4000);
// ---- Scrape popup: server or group-chat trees ----
const scrapeModal = document.createElement("div");