Tauri 2 shell with a React/TypeScript interface and libmpv playback composed beneath the web view (DirectComposition on Windows). Shared code with per-OS platform modules and configs so macOS and Linux can follow. - Plex sign-in (browser, plex.tv/link or manual), server selection, Plex Home - Home, Movies and TV Shows (Discover, Library, Collections), search, people - Title pages with logos, ratings, cast, extras, seasons and episodes - Direct play with Plex conversion fallback, tracks, markers, autoplay - Metadata editing, artwork, fix match, refresh, analyze and deletion - Resumable offline downloads - App settings and Plex server administration with a live dashboard - Signed updater feed and Forgejo CI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
2.4 KiB
TypeScript
53 lines
2.4 KiB
TypeScript
import { useMemo } from 'react';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import * as api from '../plex/api';
|
|
import { useSections, useServerQuery } from '../app/queries';
|
|
import { useServer } from '../app/session';
|
|
import { navigate } from '../app/router';
|
|
import { Hero } from '../ui/Hero';
|
|
import { HubShelf } from '../ui/media';
|
|
import { ErrorState, PageLoader } from '../ui/primitives';
|
|
import { buildFeatures, HIDDEN_HUBS } from './discover';
|
|
|
|
export function Home() {
|
|
const server = useServer();
|
|
const sections = useSections();
|
|
const video = (sections.data ?? []).filter((s) => (s.type === 'movie' || s.type === 'show') && !s.hidden);
|
|
|
|
const home = useServerQuery(['homeHubs'], (s) => api.homeHubs(s));
|
|
const continueWatching = useServerQuery(['continue'], (s) => api.continueWatching(s), { staleTime: 15_000 });
|
|
// Section hubs feed the hero and the release shelves; shared with Discover.
|
|
const sectionHubs = useQuery({
|
|
queryKey: [server.machineId, 'sectionHubsAll', video.map((s) => s.id).join(',')],
|
|
queryFn: async () => (await Promise.all(video.map((s) => api.sectionHubs(server, s.id).catch(() => [])))).flat(),
|
|
enabled: video.length > 0,
|
|
staleTime: 60_000,
|
|
});
|
|
|
|
const features = useMemo(() => buildFeatures(sectionHubs.data ?? [], 8), [sectionHubs.data]);
|
|
const extra = (sectionHubs.data ?? []).filter((h) => /recentlyreleased|recentlyaired|topunwatched|toprated/.test(h.id));
|
|
|
|
if (home.isError && !home.data) return <ErrorState error={home.error} onRetry={() => home.refetch()} />;
|
|
if (!home.data || sections.isLoading) return <PageLoader />;
|
|
|
|
const hubs = home.data.filter((h) => !HIDDEN_HUBS.test(h.id));
|
|
const cw = continueWatching.data ?? [];
|
|
const homeIds = new Set(hubs.map((h) => h.title));
|
|
|
|
return (
|
|
<div className="home">
|
|
<Hero features={features} variant="home" />
|
|
<div className="shelves over-hero">
|
|
<HubShelf title="Continue Watching" items={cw} continueWatching />
|
|
{hubs.map((h) => (
|
|
<HubShelf key={h.id} title={h.title} items={h.items} onViewAll={h.more ? () => navigate({ name: 'hub', key: h.key, title: h.title }) : undefined} />
|
|
))}
|
|
{extra
|
|
.filter((h) => !homeIds.has(h.title))
|
|
.map((h) => (
|
|
<HubShelf key={h.id} title={h.title} items={h.items} onViewAll={() => navigate({ name: 'hub', key: h.key, title: h.title })} />
|
|
))}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|