feat(plex): S6 frontend — language threading, rating badge, i18n parity
E5 S6 frontend half. Language threading (?lang=hu serves the HU overlay; en is the default): - api/plex.ts: `lang` on plexLibrary / plexFacets / plexItem / plexShow (only sent for hu, so EN URLs stay byte-stable); PlexItemDetail gains `rating`. - queryKeys: plexItem / plexShow take an optional trailing lang so a switch caches HU/EN separately; the ...rest keys (library/facets) already carry it. Prefix invalidations (qk.plexShow(id) / qk.plexItem(id)) still match either. - i18n: plexLang() collapses the UI language to en|hu for non-component code. - PlexBrowse / PlexSidebar: thread lang into the grid, facets, item and show queries (useTranslation re-renders on switch → the key changes → refetch). - plexPlayerHooks: the optimistic resume setQueryData now keys by plexLang() so it still lands on the language-keyed detail query. - Clear the genre-filter selection on a language switch — genre chips are language-specific strings, so a stale one silently empties the grid. IMDb-only rating badge (folded-in S5b review #5): - PlexInfo.tsx shows the IMDb badge + imdb.com link only when imdb_rating is present; otherwise it renders the Plex audience `rating` (no IMDb link/branding), so a non-IMDb score is never mislabelled. ratingMin filter keys off whichever score is shown. Tests: i18n parity.test.ts (en/hu key sets identical per namespace — currently green, no drift). FE gate green: tsc / knip / lint clean, 213 vitest tests pass.
This commit is contained in:
@@ -121,6 +121,7 @@ export interface PlexItemDetail {
|
||||
imdb_rating?: number | null;
|
||||
imdb_id?: string | null;
|
||||
imdb_url?: string | null;
|
||||
rating?: number | null; // Plex audience score — shown when there's no IMDb score
|
||||
content_rating?: string | null;
|
||||
genres: string[];
|
||||
directors: string[];
|
||||
@@ -285,6 +286,7 @@ export const plexApi = {
|
||||
field?: PlexSearchField; // search scope-pill (all | title | people | summary | episode)
|
||||
sort?: SortState;
|
||||
show?: string;
|
||||
lang?: string; // active UI language: "hu" serves the HU overlay twin, else EN (default)
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
filters?: PlexFilters;
|
||||
@@ -297,16 +299,18 @@ export const plexApi = {
|
||||
u.set("sort_dir", p.sort.dir);
|
||||
}
|
||||
if (p.show && p.show !== "all") u.set("show", p.show);
|
||||
if (p.lang === "hu") u.set("lang", "hu"); // en is the server default; omit to keep URLs stable
|
||||
if (p.offset) u.set("offset", String(p.offset));
|
||||
if (p.limit) u.set("limit", String(p.limit));
|
||||
if (p.filters) appendPlexFilters(u, p.filters);
|
||||
return req(`/api/plex/library?${u.toString()}`);
|
||||
},
|
||||
// Facets ADAPT to the active filters + watch-state (faceted search) — pass them so each group
|
||||
// narrows the others and the bounds match the visible result set.
|
||||
plexFacets: (scope: string, f?: PlexFilters, show?: string): Promise<PlexFacets> => {
|
||||
// narrows the others and the bounds match the visible result set. `lang` picks the genre vocabulary.
|
||||
plexFacets: (scope: string, f?: PlexFilters, show?: string, lang?: string): Promise<PlexFacets> => {
|
||||
const u = new URLSearchParams({ scope });
|
||||
if (show && show !== "all") u.set("show", show);
|
||||
if (lang === "hu") u.set("lang", "hu");
|
||||
if (f) appendPlexFilters(u, f);
|
||||
return req(`/api/plex/facets?${u.toString()}`);
|
||||
},
|
||||
@@ -400,8 +404,8 @@ export const plexApi = {
|
||||
method: "PUT",
|
||||
body: JSON.stringify({ item_rating_keys: itemRks }),
|
||||
}),
|
||||
plexShow: (id: string): Promise<PlexShowDetail> =>
|
||||
req(`/api/plex/show/${encodeURIComponent(id)}`),
|
||||
plexShow: (id: string, lang?: string): Promise<PlexShowDetail> =>
|
||||
req(`/api/plex/show/${encodeURIComponent(id)}${lang === "hu" ? "?lang=hu" : ""}`),
|
||||
// Mark a whole show / season watched or unwatched (all its episodes) for the current user.
|
||||
plexShowState: (rk: string, watched: boolean): Promise<{ changed: number; watched: boolean }> =>
|
||||
req(`/api/plex/show/${encodeURIComponent(rk)}/state`, {
|
||||
@@ -413,8 +417,8 @@ export const plexApi = {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ watched }),
|
||||
}),
|
||||
plexItem: (id: string): Promise<PlexItemDetail> =>
|
||||
req(`/api/plex/item/${encodeURIComponent(id)}`),
|
||||
plexItem: (id: string, lang?: string): Promise<PlexItemDetail> =>
|
||||
req(`/api/plex/item/${encodeURIComponent(id)}${lang === "hu" ? "?lang=hu" : ""}`),
|
||||
// Cards for the actor filter-chips currently applied: name + cached headshot + in-scope film/show count.
|
||||
plexPeopleCards: (names: string[], scope: string): Promise<{ people: PlexPersonCard[] }> =>
|
||||
req(
|
||||
|
||||
Reference in New Issue
Block a user