fix(api): search survives a down TMDB and errors name the upstream

This commit is contained in:
Miguel Palhas
2026-08-24 18:52:15 +01:00
parent e9806d7a84
commit ddf1c5fd93
4 changed files with 185 additions and 17 deletions
+12 -2
View File
@@ -576,11 +576,21 @@ function searchMain(
(hit): hit is LibrarySeriesHit => hit.kind === "series",
);
const inLibrary = new Set([...libraryMovies, ...librarySeries].map((title) => title.tmdb_id));
// Issue #168: an unreachable TMDB degrades only its own group — the
// operator sees the library half plus why TMDB is missing, and can tell
// that apart from a clean "nothing found".
const tmdbDown = response.tmdb_status === "unavailable";
if (response.library.length === 0 && response.tmdb.length === 0) {
setStatus("no matches in library or on tmdb");
setStatus(
tmdbDown ? "no matches in library — tmdb unavailable" : "no matches in library or on tmdb",
);
return;
}
setStatus(null);
if (tmdbDown) {
setStatus("tmdb unavailable — showing library matches only", "fault");
} else {
setStatus(null);
}
if (response.library.length > 0) {
refs.groups.library.section.hidden = false;
+8
View File
@@ -66,10 +66,18 @@ export interface TmdbSeries {
export type TmdbResult = TmdbMovie | TmdbSeries;
/**
* Why the tmdb group is what it is. "ok" with an empty tmdb array means
* TMDB answered and found nothing; "unavailable" means TMDB could not be
* reached — the library results still came back (issue #168).
*/
export type TmdbStatus = "ok" | "unavailable";
export interface SearchResponse {
kind: SearchInputKind;
library: LibraryResult[];
tmdb: TmdbResult[];
tmdb_status: TmdbStatus;
manual: string | null;
}