feat: multi-page improvements, bug fixes, and new features
Library: - Exclude hidden entries from all/movies/tv/favorites tabs (only show in hidden tab) Entry Details: - Move favorite, mark watched, and more actions to top-right as icon-only buttons with tooltips - Fix season card play button — marks next unwatched episode as seen Seasons Page: - Fix episode watch button (was a TODO stub, now calls createEpisodeSeen) Episode Page: - Fix UI not updating after deleting the last watch record — invalidate season episodes query on delete Dashboard: - Fix Top Genres 404 — was calling non-existent GET /statistics, now uses /statistics/watch-time - Fix TopGenresChart genre counting (Genre objects were wrongly cast as strings) - Add LibraryGrowthChart (cumulative titles added over time) - Add MediaTypeChart (Movies vs TV Series donut chart) Home Page: - Add TrendingSlider hero at top of page with auto-advance, dots, and prev/next nav - Fix slider prev/next buttons (stable callbacks via ref, plain buttons, reactive library state) - Add debounce (400ms) to search input - Add Top Rated section (movies & TV) - Add Upcoming section (movies) - Replace inline "More" expand with link to /discover/:category Discover Page (new): - Full-page TMDB browser per category (trending/popular/top-rated/upcoming) - Movie/TV tab toggle - IntersectionObserver infinite scroll Calendar: - Fix large season numbers — use season.season_number instead of season_id (DB primary key) Backend: - Add fetchTopRated() and fetchUpcoming() to tmdbService - Add GET /entries/tmdb/top-rated/:type and /entries/tmdb/upcoming/movie routes
This commit is contained in:
1 parent
d60d142d17
commit
ab20a5e64f
23 files changed
+820
-104
No files matched your search
@@ -4,6 +4,7 @@ import { ChevronDown, ChevronUp, Play } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Progress } from '@/components/ui/progress';
|
||||
import { getYear, getTmdbPosterUrl } from '@/lib/media-utils';
|
||||
import { useCreateEpisodeSeen } from '@/hooks/useEpisodeSeen';
|
||||
import type { Season } from '@/types';
|
||||
|
||||
interface SeasonsContainerProps {
|
||||
@@ -64,6 +65,7 @@ function SeasonItem({
|
||||
season: Season;
|
||||
entryId: number;
|
||||
}) {
|
||||
const createEpisodeSeen = useCreateEpisodeSeen();
|
||||
const watchedCount =
|
||||
season.episodes?.filter(
|
||||
(ep) => ep.date_first_seen || (ep.episodeSeens && ep.episodeSeens.length > 0)
|
||||
@@ -71,6 +73,11 @@ function SeasonItem({
|
||||
const totalEpisodes = season.episode_count || season.episodes?.length || 0;
|
||||
const progress = totalEpisodes > 0 ? (watchedCount / totalEpisodes) * 100 : 0;
|
||||
|
||||
const nextUnwatched = season.episodes
|
||||
?.slice()
|
||||
.sort((a, b) => a.episode_number - b.episode_number)
|
||||
.find((ep) => !ep.date_first_seen && (!ep.episodeSeens || ep.episodeSeens.length === 0));
|
||||
|
||||
return (
|
||||
<Link
|
||||
to={`/entry/${entryId}/season/${season.id}`}
|
||||
@@ -103,7 +110,7 @@ function SeasonItem({
|
||||
</div>
|
||||
|
||||
{/* Quick watch button */}
|
||||
{watchedCount < totalEpisodes && (
|
||||
{nextUnwatched && (
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
@@ -111,8 +118,13 @@ function SeasonItem({
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// TODO: Mark next unwatched episode as seen
|
||||
createEpisodeSeen.mutate({
|
||||
entry_id: entryId,
|
||||
episode_id: nextUnwatched.id,
|
||||
date_seen: new Date().toISOString(),
|
||||
});
|
||||
}}
|
||||
disabled={createEpisodeSeen.isPending}
|
||||
>
|
||||
<Play className="h-4 w-4" />
|
||||
</Button>
|
||||
|
||||
@@ -11,7 +11,8 @@ interface TrendingGridProps {
|
||||
movieEntries: TmdbEntry[];
|
||||
tvEntries: TmdbEntry[];
|
||||
isLoading?: boolean;
|
||||
moreLink: string;
|
||||
/** Route segment used for the "More" link, e.g. "trending" → /discover/trending */
|
||||
category: string;
|
||||
}
|
||||
|
||||
export function TrendingGrid({
|
||||
@@ -19,12 +20,10 @@ export function TrendingGrid({
|
||||
movieEntries,
|
||||
tvEntries,
|
||||
isLoading,
|
||||
moreLink,
|
||||
category,
|
||||
}: TrendingGridProps) {
|
||||
const [activeTab, setActiveTab] = useState<'movie' | 'tv'>('movie');
|
||||
const entries = activeTab === 'movie' ? movieEntries : tvEntries;
|
||||
|
||||
// Limit to 2 rows (14 items for a 7-column grid)
|
||||
const displayEntries = entries.slice(0, 14);
|
||||
|
||||
return (
|
||||
@@ -45,11 +44,13 @@ export function TrendingGrid({
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
<Button variant="ghost" size="sm" asChild>
|
||||
<Link to={moreLink}>
|
||||
More <ChevronRight className="ml-1 h-4 w-4" />
|
||||
</Link>
|
||||
</Button>
|
||||
<Link
|
||||
to={`/discover/${category}`}
|
||||
className="inline-flex items-center gap-1 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
More
|
||||
<ChevronRight className="h-4 w-4" />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
import { useState, useEffect, useCallback, useRef } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { ChevronLeft, ChevronRight, Star } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useCreateEntry } from '@/hooks/useEntries';
|
||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||
import type { TmdbEntry } from '@/types';
|
||||
|
||||
interface TrendingSliderProps {
|
||||
entries: TmdbEntry[];
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
export function TrendingSlider({ entries, isLoading }: TrendingSliderProps) {
|
||||
const [currentIndex, setCurrentIndex] = useState(0);
|
||||
const createEntry = useCreateEntry();
|
||||
const display = entries.slice(0, 10);
|
||||
const countRef = useRef(display.length);
|
||||
countRef.current = display.length;
|
||||
|
||||
const next = useCallback(() => {
|
||||
if (countRef.current === 0) return;
|
||||
setCurrentIndex((i) => (i + 1) % countRef.current);
|
||||
}, []);
|
||||
|
||||
const prev = useCallback(() => {
|
||||
if (countRef.current === 0) return;
|
||||
setCurrentIndex((i) => (i - 1 + countRef.current) % countRef.current);
|
||||
}, []);
|
||||
|
||||
// Reset index when entries change so it stays in range
|
||||
useEffect(() => {
|
||||
setCurrentIndex(0);
|
||||
}, [entries.length]);
|
||||
|
||||
useEffect(() => {
|
||||
if (display.length === 0) return;
|
||||
const timer = setInterval(next, 6000);
|
||||
return () => clearInterval(timer);
|
||||
}, [next, display.length]);
|
||||
|
||||
if (isLoading || display.length === 0) {
|
||||
return (
|
||||
<div className="relative h-85 sm:h-100 rounded-2xl bg-muted animate-pulse" />
|
||||
);
|
||||
}
|
||||
|
||||
const safeIndex = currentIndex < display.length ? currentIndex : 0;
|
||||
const item = display[safeIndex];
|
||||
const title = item.title || item.name || 'Untitled';
|
||||
const backdropUrl = item.backdrop_path
|
||||
? `https://image.tmdb.org/t/p/w1280${item.backdrop_path}`
|
||||
: null;
|
||||
const isTv = item.media_type === 'tv' || !!item.name;
|
||||
|
||||
const libraryEntries = useLibraryStore((s) => s.entries);
|
||||
const matchedEntry = Array.from(libraryEntries.values()).find(
|
||||
(e) => e.entryIds?.tmdb_id === item.id
|
||||
);
|
||||
const isInLibrary = !!matchedEntry;
|
||||
|
||||
return (
|
||||
<div className="relative h-85 sm:h-100 rounded-2xl overflow-hidden group">
|
||||
{/* Backdrop */}
|
||||
{backdropUrl ? (
|
||||
<img
|
||||
src={backdropUrl}
|
||||
alt=""
|
||||
className="absolute inset-0 h-full w-full object-cover transition-transform duration-700 group-hover:scale-105"
|
||||
/>
|
||||
) : (
|
||||
<div className="absolute inset-0 bg-linear-to-br from-primary/20 to-primary/5" />
|
||||
)}
|
||||
<div className="absolute inset-0 bg-linear-to-t from-black/90 via-black/40 to-transparent" />
|
||||
|
||||
{/* Nav arrows */}
|
||||
<button
|
||||
type="button"
|
||||
className="absolute left-3 top-1/2 -translate-y-1/2 z-20 h-10 w-10 rounded-full bg-black/40 text-white hover:bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center cursor-pointer"
|
||||
onClick={(e) => { e.stopPropagation(); prev(); }}
|
||||
>
|
||||
<ChevronLeft className="h-5 w-5" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="absolute right-3 top-1/2 -translate-y-1/2 z-20 h-10 w-10 rounded-full bg-black/40 text-white hover:bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center cursor-pointer"
|
||||
onClick={(e) => { e.stopPropagation(); next(); }}
|
||||
>
|
||||
<ChevronRight className="h-5 w-5" />
|
||||
</button>
|
||||
|
||||
{/* Content overlay */}
|
||||
<div className="absolute bottom-0 left-0 right-0 p-6 sm:p-8 z-10">
|
||||
<div className="max-w-2xl space-y-3">
|
||||
<div className="flex items-center gap-2 text-white/70 text-sm">
|
||||
<span className="uppercase font-medium tracking-wider text-xs bg-white/20 backdrop-blur-sm px-2 py-0.5 rounded">
|
||||
{isTv ? 'TV Series' : 'Movie'}
|
||||
</span>
|
||||
{item.vote_average > 0 && (
|
||||
<span className="flex items-center gap-1">
|
||||
<Star className="h-3.5 w-3.5 fill-yellow-400 text-yellow-400" />
|
||||
{item.vote_average.toFixed(1)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<h2 className="text-2xl sm:text-4xl font-bold text-white leading-tight">
|
||||
{title}
|
||||
</h2>
|
||||
{item.overview && (
|
||||
<p className="text-sm text-white/80 line-clamp-2 max-w-xl">
|
||||
{item.overview}
|
||||
</p>
|
||||
)}
|
||||
<div className="flex items-center gap-3 pt-1">
|
||||
{isInLibrary && matchedEntry ? (
|
||||
<Link to={`/entry/${matchedEntry.id}`}>
|
||||
<Button size="sm" className="rounded-full px-5">
|
||||
View Details
|
||||
</Button>
|
||||
</Link>
|
||||
) : (
|
||||
<Button
|
||||
size="sm"
|
||||
className="rounded-full px-5"
|
||||
onClick={() => createEntry.mutate({ tmdb_id: item.id, is_tvserie: isTv })}
|
||||
disabled={createEntry.isPending}
|
||||
>
|
||||
Add to Library
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Dots */}
|
||||
<div className="absolute bottom-3 right-6 flex gap-1.5 z-10">
|
||||
{display.map((_, i) => (
|
||||
<button
|
||||
key={i}
|
||||
onClick={() => setCurrentIndex(i)}
|
||||
className={`h-1.5 rounded-full transition-all ${
|
||||
i === currentIndex
|
||||
? 'w-6 bg-white'
|
||||
: 'w-1.5 bg-white/40 hover:bg-white/60'
|
||||
}`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user