Startup now uses the Android iris animation, and playback can continue in a corner miniplayer while browsing (the video is drawn into a corner rectangle beneath a matching hole in the page). The player keeps the window controls, hides its chrome when the pointer leaves, and gains audio/subtitle tracks, audio sync, source bitrate and playback details in its options. Subtitles can be styled in Settings with a live preview. Categories replace Collections, the A–Z rail magnifies, descriptions expand in place, downloads can be removed in bulk, and search keeps its results while typing. Fixes scroll jank from per-card and scrolling backdrop blurs, the hidden colour wash, the cubic volume curve, loud theme music, the search focus ring, a stray nav indicator, Continue Watching previews and the TV Shows header overlap. Removes the star rating, the duplicate Settings menu entry and the server settings' Show advanced switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
150 lines
6.9 KiB
TypeScript
150 lines
6.9 KiB
TypeScript
import { useMemo } from 'react';
|
|
import * as api from '../plex/api';
|
|
import { useSectionFor, useServerQuery } from '../app/queries';
|
|
import { navigate, useRouter, type SectionKind, type SectionTab } from '../app/router';
|
|
import { useSettings } from '../app/settings';
|
|
import type { Section } from '../plex/types';
|
|
import { Hero } from '../ui/Hero';
|
|
import { HubShelf } from '../ui/media';
|
|
import { useServer } from '../app/session';
|
|
import { Icon } from '../ui/Icon';
|
|
import { categoryArtwork } from './categories';
|
|
import { Artwork, EmptyState, ErrorState, PageLoader, Select } from '../ui/primitives';
|
|
import { buildFeatures, HIDDEN_HUBS, recentSeasons } from './discover';
|
|
import { LibraryBrowser } from './LibraryBrowser';
|
|
|
|
const TABS: { id: SectionTab; label: string }[] = [
|
|
{ id: 'discover', label: 'Discover' },
|
|
{ id: 'library', label: 'Library' },
|
|
{ id: 'categories', label: 'Categories' },
|
|
];
|
|
|
|
function SectionHeader({ kind, tab, section, all, overlay }: { kind: SectionKind; tab: SectionTab; section: Section; all: Section[]; overlay: boolean }) {
|
|
const set = useSettings((s) => s.set);
|
|
return (
|
|
<div className={`section-header${overlay ? ' overlay' : ''}`}>
|
|
<h1>{kind === 'movie' ? 'Movies' : 'TV Shows'}</h1>
|
|
<nav className="section-tabs" role="tablist">
|
|
{TABS.map((t) => (
|
|
<button key={t.id} role="tab" aria-selected={t.id === tab} className={t.id === tab ? 'active' : ''} onClick={() => navigate({ name: 'section', kind, tab: t.id }, { replace: true })}>
|
|
{t.label}
|
|
</button>
|
|
))}
|
|
</nav>
|
|
{all.length > 1 && (
|
|
<Select
|
|
className="section-picker"
|
|
value={section.id}
|
|
label="Library"
|
|
options={all.map((s) => ({ value: s.id, label: s.title }))}
|
|
onChange={(v) => set(kind === 'movie' ? 'movieSection' : 'showSection', v)}
|
|
/>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function Discover({ kind, section }: { kind: SectionKind; section: Section }) {
|
|
const hubs = useServerQuery(['sectionHubs', section.id], (s) => api.sectionHubs(s, section.id));
|
|
const cw = useServerQuery(['continue', section.id], (s) => api.continueWatching(s, section.id), { staleTime: 15_000 });
|
|
const seasons = useServerQuery(['recentSeasons', section.id], (s) => recentSeasons(s, section.id), { enabled: kind === 'show', staleTime: 120_000 });
|
|
const features = useMemo(() => buildFeatures(hubs.data ?? [], 7, kind === 'movie' ? 1 : 2), [hubs.data, kind]);
|
|
|
|
if (hubs.isError && !hubs.data) return <ErrorState error={hubs.error} onRetry={() => hubs.refetch()} />;
|
|
if (!hubs.data) return <PageLoader />;
|
|
const rest = hubs.data.filter((h) => !HIDDEN_HUBS.test(h.id));
|
|
// TV: episodes lead; redundant episode hubs are skipped when they repeat Continue Watching.
|
|
const cwIds = new Set((cw.data ?? []).map((i) => i.id));
|
|
const shelves = rest.filter((h) => !(h.items.length && h.items.every((i) => cwIds.has(i.id))));
|
|
return (
|
|
<>
|
|
<Hero features={features} variant="section" />
|
|
<div className="shelves over-hero">
|
|
<HubShelf title={kind === 'show' ? 'Next Episodes' : 'Continue Watching'} items={cw.data ?? []} continueWatching />
|
|
{kind === 'show' && <HubShelf title="New Seasons" items={seasons.data ?? []} landscape={false} />}
|
|
{shelves.map((h) => (
|
|
<HubShelf key={h.id} title={h.title.replace(/ in (Movies|TV Shows)$/, '')} items={h.items} onViewAll={h.more || h.key.includes('/all') ? () => navigate({ name: 'hub', key: h.key, title: h.title }) : undefined} />
|
|
))}
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
|
|
/** Genres as artwork tiles, as on Kaleido for TV; each opens the library filtered to it. */
|
|
function Categories({ kind, section }: { kind: SectionKind; section: Section }) {
|
|
const server = useServer();
|
|
const type = kind === 'movie' ? 1 : 2;
|
|
const genres = useServerQuery(['genres', section.id, type], (s) => api.genres(s, section.id, type), { staleTime: 30 * 60_000 });
|
|
const artwork = useServerQuery(['categoryArtwork', section.id, type, genres.data?.map((g) => g.key).join(',')], (s) => categoryArtwork(s, section.id, type, genres.data ?? []), {
|
|
enabled: !!genres.data?.length,
|
|
staleTime: 30 * 60_000,
|
|
});
|
|
if (genres.isError) return <ErrorState error={genres.error} onRetry={() => genres.refetch()} />;
|
|
if (!genres.data) return <PageLoader />;
|
|
if (!genres.data.length)
|
|
return (
|
|
<EmptyState icon="grid" title="No categories">
|
|
{section.title} has no genres yet.
|
|
</EmptyState>
|
|
);
|
|
return (
|
|
<div className="page-pad">
|
|
<div className="category-grid">
|
|
{genres.data.map((g) => {
|
|
const path = artwork.data?.[g.key];
|
|
return (
|
|
<button key={g.key} className="category-tile" onClick={() => navigate({ name: 'section', kind, tab: 'categories', genre: g.key, genreTitle: g.title })}>
|
|
{path && <Artwork src={server.image(path, 540, 304)} />}
|
|
<span className="category-scrim" />
|
|
<span className="category-title">{g.title}</span>
|
|
</button>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/** Back to the grid: pop the history entry when that's where the genre was opened from. */
|
|
function backToCategories(kind: SectionKind) {
|
|
const { entries, index, back } = useRouter.getState();
|
|
const prev = entries[index - 1]?.route;
|
|
if (prev?.name === 'section' && prev.tab === 'categories' && !prev.genre) back();
|
|
else navigate({ name: 'section', kind, tab: 'categories' }, { replace: true });
|
|
}
|
|
|
|
function CategoryLibrary({ kind, section, genre, title }: { kind: SectionKind; section: Section; genre: string; title: string }) {
|
|
return (
|
|
<>
|
|
<div className="category-head">
|
|
<button className="category-back" onClick={() => backToCategories(kind)}>
|
|
<Icon name="back" size={16} />
|
|
Categories
|
|
</button>
|
|
<h2>{title}</h2>
|
|
</div>
|
|
<LibraryBrowser section={section} kind={kind} lockedFilters={{ genre }} />
|
|
</>
|
|
);
|
|
}
|
|
|
|
export function SectionScreen({ kind, tab, genre, genreTitle }: { kind: SectionKind; tab: SectionTab; genre?: string; genreTitle?: string }) {
|
|
const { section, all, loading } = useSectionFor(kind);
|
|
if (loading) return <PageLoader />;
|
|
if (!section)
|
|
return (
|
|
<div className="page-pad top">
|
|
<EmptyState icon={kind === 'movie' ? 'film' : 'tv'} title={`No ${kind === 'movie' ? 'movie' : 'TV'} libraries`}>
|
|
This server has no {kind === 'movie' ? 'movie' : 'TV show'} libraries you can access.
|
|
</EmptyState>
|
|
</div>
|
|
);
|
|
return (
|
|
<div className={`section-screen tab-${tab}`} key={section.id}>
|
|
<SectionHeader kind={kind} tab={tab} section={section} all={all} overlay={tab === 'discover'} />
|
|
{tab === 'discover' && <Discover kind={kind} section={section} />}
|
|
{tab === 'library' && <LibraryBrowser section={section} kind={kind} />}
|
|
{tab === 'categories' && (genre ? <CategoryLibrary kind={kind} section={section} genre={genre} title={genreTitle ?? ''} /> : <Categories kind={kind} section={section} />)}
|
|
</div>
|
|
);
|
|
}
|