Merge #172: search returns titles only

Closes #172
This commit is contained in:
Miguel Palhas
2026-08-24 16:40:44 +01:00
4 changed files with 30 additions and 195 deletions
+1 -43
View File
@@ -65,7 +65,6 @@ import {
addSeries,
allRoots,
fetchMovie,
type LibraryEpisodeHit,
type LibraryMovie,
type LibrarySeriesHit,
parseManualInput,
@@ -563,17 +562,13 @@ function searchMain(
return;
}
// §9.2: in-library hits read as whatever they are — a movie, a series,
// or an episode with its series and SxxEyy for context
// §9.2: in-library hits read as whatever they are — a movie or a series.
const libraryMovies = response.library.filter(
(hit): hit is LibraryMovie => hit.kind === "movie",
);
const librarySeries = response.library.filter(
(hit): hit is LibrarySeriesHit => hit.kind === "series",
);
const libraryEpisodes = response.library.filter(
(hit): hit is LibraryEpisodeHit => hit.kind === "episode",
);
const inLibrary = new Set([...libraryMovies, ...librarySeries].map((title) => title.tmdb_id));
if (response.library.length === 0 && response.tmdb.length === 0) {
setStatus("no matches in library or on tmdb");
@@ -590,9 +585,6 @@ function searchMain(
for (const series of librarySeries) {
refs.groups.library.rows.append(librarySeriesRow(series, roots, openSeries));
}
for (const episode of libraryEpisodes) {
refs.groups.library.rows.append(episodeRow(episode, openSeries));
}
}
if (response.tmdb.length > 0) {
refs.groups.tmdb.section.hidden = false;
@@ -972,40 +964,6 @@ function librarySeriesRow(
return item;
}
/** An in-library episode hit: its series, the `SxxEyy` tag, then the title. */
function episodeRow(
episode: LibraryEpisodeHit,
open: (id: number, origin: HTMLElement) => void,
): HTMLLIElement {
const { item, row, body, chips } = richRow();
chips.append(
chip(episode.tag, (span) => {
span.setAttribute("aria-label", `${episode.series_title} ${episode.tag}, ${episode.title}`);
}),
);
// the episode title is a name, not a readout: sans, never mono
const title = document.createElement("span");
title.className = "row-sub";
title.textContent = episode.title;
chips.append(title);
const rating = ratingChip(episode.vote_average);
if (rating !== null) {
chips.append(rating);
}
chips.append(trailerChip("tv", episode.series_tmdb_id));
const affordance = document.createElement("span");
affordance.className = "row-add readout";
affordance.textContent = "episodes";
chips.append(affordance);
body.append(rowTitle(episode.series_title, null), chips);
row.append(rowPoster(episode.poster_path, episode.series_title), body);
row.addEventListener("click", () => {
open(episode.series_id, row);
});
item.append(row);
return item;
}
/** A TMDB hit of either kind — the row opens the add flow (§9.2). */
function tmdbRow(
hit: TmdbMovie | TmdbSeries,