fix(api): search survives a down TMDB and errors name the upstream
This commit is contained in:
+12
-2
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user