Drive provider filters from the archive dataset

This commit is contained in:
Fisto
2026-09-17 11:11:31 +02:00
parent 8cb1faf8b4
commit 7c9aa43e10
10 changed files with 84 additions and 26 deletions
+10 -8
View File
@@ -1332,7 +1332,14 @@
function toggleFilterDrawer() {
filterDrawer.hidden = !filterDrawer.hidden;
if (!filterDrawer.hidden) renderFilterDrawer();
if (!filterDrawer.hidden) {
renderFilterDrawer();
if (!state.status?.providerFilters?.length) {
void loadScrapes().then(() => {
if (!filterDrawer.hidden) renderFilterDrawer();
});
}
}
}
/** The drawer holds the less common filters; the basic ones live in the bar. */
@@ -1504,13 +1511,8 @@
on ? [...new Set([...list, value])] : list.filter(entry => entry !== value);
const sourceGroup = group("Sources");
for (const [value, label] of [
["twitch", "Twitch"],
["youtube", "YouTube"],
["discord", "Discord"],
["tenor", "Tenor"],
["giphy", "Giphy"]
]) {
for (const value of state.status?.providerFilters ?? []) {
const label = value.charAt(0).toUpperCase() + value.slice(1);
sourceGroup.append(
checkRow(label, draft.excludeProviders.includes(value), on => {
draft.excludeProviders = toggle(draft.excludeProviders, value, on);
+5 -1
View File
@@ -21,6 +21,7 @@ import {
resolveDbRoot,
type MediaKind,
type MediaRow,
PROVIDER_FILTERS,
type BackfillSettings,
type BackfillStatus,
type MediaSort,
@@ -160,6 +161,8 @@ export interface MediaStatus {
scrapes: ScrapeMeta[];
/** ISO time while a Discord rate limit holds media traffic. */
limitedUntil: string | null;
/** The common providers, for the "Do not include" shortcuts in the Advanced drawer. */
providerFilters: string[];
}
export class MediaService {
@@ -491,7 +494,8 @@ export class MediaService {
scrapes: this.engine.list(),
limitedUntil: limit.active
? new Date(limit.until ?? Date.now() + limit.remainingMs).toISOString()
: null
: null,
providerFilters: [...PROVIDER_FILTERS]
};
}
+18
View File
@@ -116,8 +116,26 @@ try {
step("people checkboxes", await page.locator(".vk-media-people input").count());
await page.getByRole("button", { name: /^People/ }).click();
const providerFilters = await page.evaluate(async () => {
const response = await fetch("/api/media/status");
const body = await response.json();
return body?.result?.providerFilters ?? [];
});
step("provider filters from the API", providerFilters);
await page.getByRole("button", { name: "Advanced search" }).click();
await page.waitForSelector(".vk-media-drawer:not([hidden])", { timeout: 5000 });
const sourceBoxes = await page
.locator(".vk-media-exclude-group")
.first()
.locator(".vk-media-check")
.count();
step("source checkboxes", sourceBoxes);
check(
"provider checkboxes match the API list",
sourceBoxes === providerFilters.length + 3,
{ sourceBoxes, providers: providerFilters.length }
);
await page.locator(".vk-media-check", { hasText: "Show only cached previews" }).locator("input").check();
await page.getByRole("button", { name: "Apply filters" }).click();
await page.waitForTimeout(2500);