fix(web): drop duplicate tmdb hits from search
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
73d56fe821
commit
17ad82f541
+11
-28
@@ -612,11 +612,13 @@ function searchMain(
|
||||
refs.groups.library.rows.append(librarySeriesRow(series, roots, openSeries));
|
||||
}
|
||||
}
|
||||
if (response.tmdb.length > 0) {
|
||||
// a TMDB hit already in the library group above never repeats here
|
||||
const tmdbHits = response.tmdb.filter((hit) => !inLibrary.has(hit.tmdb_id));
|
||||
if (tmdbHits.length > 0) {
|
||||
refs.groups.tmdb.section.hidden = false;
|
||||
refs.groups.tmdb.count.textContent = String(response.tmdb.length);
|
||||
for (const hit of response.tmdb) {
|
||||
refs.groups.tmdb.rows.append(tmdbRow(hit, inLibrary.has(hit.tmdb_id), fetchRoots));
|
||||
refs.groups.tmdb.count.textContent = String(tmdbHits.length);
|
||||
for (const hit of tmdbHits) {
|
||||
refs.groups.tmdb.rows.append(tmdbRow(hit, fetchRoots));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1015,30 +1017,18 @@ function librarySeriesRow(
|
||||
}
|
||||
|
||||
/** A TMDB hit of either kind — the row opens the add flow (§9.2). */
|
||||
function tmdbRow(
|
||||
hit: TmdbMovie | TmdbSeries,
|
||||
inLibrary: boolean,
|
||||
fetchRoots: () => Promise<Root[]>,
|
||||
): HTMLLIElement {
|
||||
function tmdbRow(hit: TmdbMovie | TmdbSeries, fetchRoots: () => Promise<Root[]>): HTMLLIElement {
|
||||
const { item, row, body, chips } = richRow();
|
||||
chips.append(chip(hit.original_language));
|
||||
if (inLibrary) {
|
||||
chips.append(
|
||||
chip("in library", (span) => {
|
||||
span.dataset.verdict = "eligible";
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
const add = document.createElement("span");
|
||||
add.className = "row-add readout";
|
||||
add.textContent = "add";
|
||||
chips.append(add);
|
||||
}
|
||||
const rating = ratingChip(hit.vote_average, hit.vote_count);
|
||||
if (rating !== null) {
|
||||
chips.append(rating);
|
||||
}
|
||||
chips.append(trailerChip(hit.kind === "series" ? "tv" : "movie", hit.tmdb_id));
|
||||
const add = document.createElement("span");
|
||||
add.className = "row-add control readout";
|
||||
add.textContent = "add";
|
||||
chips.append(add);
|
||||
body.append(rowTitle(hit.title, hit.year), chips);
|
||||
if (hit.overview) {
|
||||
const overview = document.createElement("span");
|
||||
@@ -1049,13 +1039,6 @@ function tmdbRow(
|
||||
row.append(rowPoster(hit.poster_path, hit.title), body);
|
||||
item.append(row);
|
||||
|
||||
if (inLibrary) {
|
||||
// aria-disabled, not disabled: a dead button would also kill the
|
||||
// trailer chip's clicks, and that chip stays live on every row
|
||||
row.setAttribute("aria-disabled", "true");
|
||||
return item;
|
||||
}
|
||||
|
||||
row.setAttribute("aria-expanded", "false");
|
||||
row.addEventListener("click", () => {
|
||||
const open = item.querySelector(".add-panel");
|
||||
|
||||
Reference in New Issue
Block a user