feat(streaming): add watch button to episode cards and episode details page
- Add play overlay on episode thumbnails in SeasonPage (click to stream directly) - Add clickable watch overlay on episode still image in EpisodePage - Fix StreamingDialog rendering via React portal (document.body) to prevent ancestor overflow/max-width clipping - Fix EpisodePage JSX parse error (streaming dialog was outside root element) - Fix watch buttons not working: use useEntry hook for full entry data with entryIds instead of library store (which lacks entryIds) - Fix preventDefault called after guard check, causing link navigation when tmdb_id was missing - Pass seasons via useEntrySeasons to StreamingDialog from both pages so episodes sidebar renders correctly - Apply final UI polish: entry title in dialog top bar, season selector label, episode format "E1 Title", watched badge always-on, unreleased episodes greyed out
This commit is contained in:
1 parent
afc032ca1c
commit
022c9a271b
7 files changed
+708
-518
No files matched your search
@@ -1,14 +1,16 @@
|
||||
import { useState } from 'react';
|
||||
import { useParams, Link } from 'react-router-dom';
|
||||
import { useSeason, useSeasonEpisodes } from '@/hooks/useSeasons';
|
||||
|
||||
import { useEntry, useEntrySeasons } from '@/hooks/useEntries';
|
||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||
import { EpisodeSeenEditDialog } from '@/components/dialogs/EpisodeSeenEditDialog';
|
||||
import { MarkSeasonWatchedDialog } from '@/components/dialogs/MarkSeasonWatchedDialog';
|
||||
import { StreamingDialog } from '@/components/streaming/StreamingDialog';
|
||||
import { useStreamingStore } from '@/stores/useStreamingStore';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Progress } from '@/components/ui/progress';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Eye, CheckCircle2, ListChecks } from 'lucide-react';
|
||||
import { Eye, CheckCircle2, ListChecks, PlayCircle } from 'lucide-react';
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
import { getTmdbPosterUrl, getYear, formatDate } from '@/lib/media-utils';
|
||||
import type { Episode, EpisodeSeen } from '@/types';
|
||||
@@ -20,9 +22,26 @@ export function SeasonPage() {
|
||||
}>();
|
||||
const { data: season, isLoading } = useSeason(parseInt(seasonId!, 10));
|
||||
const { data: episodes = [] } = useSeasonEpisodes(parseInt(seasonId!, 10));
|
||||
const entryTitle = useLibraryStore((s) => s.entries.get(parseInt(entryId!, 10))?.title);
|
||||
const { data: entry } = useEntry(parseInt(entryId!, 10));
|
||||
const { data: entrySeasons } = useEntrySeasons(parseInt(entryId!, 10));
|
||||
const entryTitle = entry?.title ?? useLibraryStore.getState().entries.get(parseInt(entryId!, 10))?.title;
|
||||
const { initialize, play } = useStreamingStore();
|
||||
const [dialogEpisode, setDialogEpisode] = useState<Episode | null>(null);
|
||||
const [showMarkAllDialog, setShowMarkAllDialog] = useState(false);
|
||||
const [streamingOpen, setStreamingOpen] = useState(false);
|
||||
|
||||
const handleWatchEpisode = (season: number, episodeNumber: number) => {
|
||||
if (!entry?.entryIds?.tmdb_id) return;
|
||||
initialize();
|
||||
play({
|
||||
type: 'tv',
|
||||
tmdbId: entry.entryIds.tmdb_id,
|
||||
imdbId: entry.entryIds?.imdb_id || undefined,
|
||||
season,
|
||||
episode: episodeNumber,
|
||||
});
|
||||
setStreamingOpen(true);
|
||||
};
|
||||
|
||||
if (isLoading || !season) {
|
||||
return (
|
||||
@@ -126,20 +145,31 @@ export function SeasonPage() {
|
||||
to={`/entry/${entryId}/season/${seasonId}/episode/${episode.id}`}
|
||||
className="flex gap-3 rounded-lg border border-border p-2 transition-colors hover:bg-accent/50 sm:gap-4 sm:p-3"
|
||||
>
|
||||
{/* Thumbnail */}
|
||||
<div className="h-14 w-24 shrink-0 overflow-hidden rounded bg-muted sm:h-16 sm:w-28">
|
||||
{/* Thumbnail — click to watch */}
|
||||
<div
|
||||
className="relative h-14 w-24 shrink-0 overflow-hidden rounded bg-muted sm:h-16 sm:w-28 group/thumb cursor-pointer"
|
||||
onClick={(ev) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
if (!entry?.entryIds?.tmdb_id) return;
|
||||
handleWatchEpisode(season.season_number, episode.episode_number);
|
||||
}}
|
||||
>
|
||||
{episode.still_path ? (
|
||||
<img
|
||||
src={getTmdbPosterUrl(episode.still_path, 'w300')}
|
||||
alt={episode.name}
|
||||
className="h-full w-full object-cover"
|
||||
className="h-full w-full object-cover transition-[filter] group-hover/thumb:brightness-50"
|
||||
loading="lazy"
|
||||
/>
|
||||
) : (
|
||||
<div className="flex h-full w-full items-center justify-center text-xs text-muted-foreground">
|
||||
<div className="flex h-full w-full items-center justify-center text-xs text-muted-foreground bg-muted group-hover/thumb:bg-muted/70 transition-colors">
|
||||
No Image
|
||||
</div>
|
||||
)}
|
||||
<div className="absolute inset-0 flex items-center justify-center opacity-0 group-hover/thumb:opacity-100 transition-opacity">
|
||||
<PlayCircle className="h-7 w-7 text-white drop-shadow-lg" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Info */}
|
||||
@@ -235,6 +265,19 @@ export function SeasonPage() {
|
||||
seasonId={parseInt(seasonId!, 10)}
|
||||
episodes={episodes}
|
||||
/>
|
||||
|
||||
{/* Streaming dialog */}
|
||||
{entry && streamingOpen && (
|
||||
<StreamingDialog
|
||||
isOpen={streamingOpen}
|
||||
onClose={() => {
|
||||
setStreamingOpen(false);
|
||||
useStreamingStore.getState().closePlayer();
|
||||
}}
|
||||
entry={entry}
|
||||
seasons={entrySeasons}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user