Complete frontend refactoring: UI enhancements, pagination, filtering, search architecture, and data management improvements
# Phase 1: Feature Implementation
- Add "Create new..." option in `AddEntryToCollectionDialog` for inline collection creation with auto-select
- Implement lazy loading pagination with IntersectionObserver for Watchlist, Collections, and Media pages
- Add reusable useDebounce hook (300-400ms) and apply to all search inputs across pages
- Reset scroll position to top when switching between sidebar navigation pages via useLocation()
- Reorganize MediaPage with horizontal control layout, add Media Type filter (All/Audio/Video), and Custom Media filter (Show All/Official Only/Custom Only)
- Add three-dot menu (MoreHorizontal icon) to collection cards with Edit/Delete options and "Get all parts" feature
- Replace numeric rating input with interactive star rating component in EditCollectionDialog (0-10 stars with half-star support)
- Display entry type badges ("Movie" / "TV Series") on home page trending/popular sections and search results
- Create PeopleSearchResult component with profile images; integrate useTmdbSearchPeople hook linking to `/people/tmdb/:tmdbId`
- Add TMDB Rating and User Rating filters to Library page with range sliders (0-10, step 1) and state persistence in useLibraryStore
- Add All/Movies/TV Series type filter to Watchlist page with filtered count display
- Improve People Details page mobile UI: optimize header, info section sizing, and filmography card layouts for touch
# Phase 2: Architecture Refactoring & Bug Fixes
- Fix scroll-to-top on sidebar navigation by constraining AppLayout root to `h-screen overflow-hidden` so `<main>` becomes proper scroll container
- Extract search from HomePage into dedicated SearchPage component with `/search` route, debounced input, and URL query sync via SearchParams
- Add Search nav item with icon to sidebar for easy search access
- HomePage search input now navigates to `/search?q=...` instead of handling inline, separating concerns and enabling search bookmarking
- Entry type pill badges now conditionally render via `showTypeBadge` prop on EntryCard—only SearchPage passes this to prevent display on home/discover pages
- Fix people ID bug: people search results now link to `/people/tmdb/:tmdbId` (TMDB redirect route) instead of `/people/:id`, correctly mapping TMDB IDs to local database IDs through PersonTmdbRedirectPage
- Enhance People Details filmography sorting: "Not in Library" section now detects self roles (self/themselves/himself/herself) and sorts non-self by release date (new→old) with all self roles pushed to end of list
# Summary
- Created new files: SearchPage.tsx, useDebounce.ts
This commit is contained in:
1 parent
d28b4caa7e
commit
9a8ee181e5
23 files changed
+680
-188
No files matched your search
@@ -6,30 +6,18 @@ import {
|
||||
useTopRatedMovies,
|
||||
useTopRatedTv,
|
||||
useUpcomingMovies,
|
||||
useTmdbSearch,
|
||||
} from '@/hooks/useTmdb';
|
||||
import { useLibrary } from '@/hooks/useEntries';
|
||||
import { TrendingGrid } from '@/components/entries/TrendingGrid';
|
||||
import { TrendingSlider } from '@/components/entries/TrendingSlider';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { useState, useEffect, useRef } from 'react';
|
||||
import { Search } from 'lucide-react';
|
||||
import { EntryCard } from '@/components/entries/EntryCard';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useState } from 'react';
|
||||
|
||||
export function HomePage() {
|
||||
const navigate = useNavigate();
|
||||
const [searchInput, setSearchInput] = useState('');
|
||||
const [debouncedQuery, setDebouncedQuery] = useState('');
|
||||
const debounceRef = useRef<ReturnType<typeof setTimeout>>();
|
||||
|
||||
useEffect(() => {
|
||||
if (debounceRef.current) clearTimeout(debounceRef.current);
|
||||
debounceRef.current = setTimeout(() => {
|
||||
setDebouncedQuery(searchInput);
|
||||
}, 400);
|
||||
return () => {
|
||||
if (debounceRef.current) clearTimeout(debounceRef.current);
|
||||
};
|
||||
}, [searchInput]);
|
||||
|
||||
// Pre-load library
|
||||
useLibrary();
|
||||
@@ -41,7 +29,6 @@ export function HomePage() {
|
||||
const topRatedMovies = useTopRatedMovies();
|
||||
const topRatedTv = useTopRatedTv();
|
||||
const upcomingMovies = useUpcomingMovies();
|
||||
const searchResults = useTmdbSearch(debouncedQuery);
|
||||
|
||||
const trendingMovieEntries = trendingMovies.data?.pages.flatMap((p) => p.results) ?? [];
|
||||
const trendingTvEntries = trendingTv.data?.pages.flatMap((p) => p.results) ?? [];
|
||||
@@ -50,87 +37,67 @@ export function HomePage() {
|
||||
const topRatedMovieEntries = topRatedMovies.data?.pages.flatMap((p) => p.results) ?? [];
|
||||
const topRatedTvEntries = topRatedTv.data?.pages.flatMap((p) => p.results) ?? [];
|
||||
const upcomingMovieEntries = upcomingMovies.data?.pages.flatMap((p) => p.results) ?? [];
|
||||
const searchEntries = searchResults.data?.pages.flatMap((p) => p.results) ?? [];
|
||||
|
||||
const isSearching = debouncedQuery.length > 0;
|
||||
const handleSearchSubmit = () => {
|
||||
const q = searchInput.trim();
|
||||
if (q) {
|
||||
navigate(`/search?q=${encodeURIComponent(q)}`);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-8 animate-page-enter">
|
||||
{/* Trending Slider Hero */}
|
||||
{!isSearching && (
|
||||
<TrendingSlider
|
||||
entries={trendingMovieEntries}
|
||||
isLoading={trendingMovies.isLoading}
|
||||
/>
|
||||
)}
|
||||
<TrendingSlider
|
||||
entries={trendingMovieEntries}
|
||||
isLoading={trendingMovies.isLoading}
|
||||
/>
|
||||
|
||||
{/* Search */}
|
||||
<div className="relative max-w-md">
|
||||
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
||||
<Input
|
||||
placeholder="Search movies & TV shows..."
|
||||
placeholder="Search movies, TV shows & people..."
|
||||
value={searchInput}
|
||||
onChange={(e) => setSearchInput(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') handleSearchSubmit();
|
||||
}}
|
||||
className="pl-10"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{isSearching ? (
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-xl font-semibold">
|
||||
Search Results for "{debouncedQuery}"
|
||||
</h2>
|
||||
{searchEntries.length === 0 && !searchResults.isLoading ? (
|
||||
<p className="text-muted-foreground">No results found.</p>
|
||||
) : (
|
||||
<div className="grid grid-cols-2 gap-3 sm:gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-7">
|
||||
{searchEntries.map((entry, index) => (
|
||||
<div
|
||||
key={entry.id}
|
||||
className="animate-card-enter"
|
||||
style={{ animationDelay: `${Math.min(index * 30, 300)}ms` }}
|
||||
>
|
||||
<EntryCard tmdbEntry={entry} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<TrendingGrid
|
||||
title="Trending"
|
||||
movieEntries={trendingMovieEntries}
|
||||
tvEntries={trendingTvEntries}
|
||||
isLoading={trendingMovies.isLoading || trendingTv.isLoading}
|
||||
category="trending"
|
||||
/>
|
||||
<TrendingGrid
|
||||
title="Trending"
|
||||
movieEntries={trendingMovieEntries}
|
||||
tvEntries={trendingTvEntries}
|
||||
isLoading={trendingMovies.isLoading || trendingTv.isLoading}
|
||||
category="trending"
|
||||
/>
|
||||
|
||||
<TrendingGrid
|
||||
title="Popular"
|
||||
movieEntries={popularMovieEntries}
|
||||
tvEntries={popularTvEntries}
|
||||
isLoading={popularMovies.isLoading || popularTv.isLoading}
|
||||
category="popular"
|
||||
/>
|
||||
<TrendingGrid
|
||||
title="Popular"
|
||||
movieEntries={popularMovieEntries}
|
||||
tvEntries={popularTvEntries}
|
||||
isLoading={popularMovies.isLoading || popularTv.isLoading}
|
||||
category="popular"
|
||||
/>
|
||||
|
||||
<TrendingGrid
|
||||
title="Top Rated"
|
||||
movieEntries={topRatedMovieEntries}
|
||||
tvEntries={topRatedTvEntries}
|
||||
isLoading={topRatedMovies.isLoading || topRatedTv.isLoading}
|
||||
category="top-rated"
|
||||
/>
|
||||
<TrendingGrid
|
||||
title="Top Rated"
|
||||
movieEntries={topRatedMovieEntries}
|
||||
tvEntries={topRatedTvEntries}
|
||||
isLoading={topRatedMovies.isLoading || topRatedTv.isLoading}
|
||||
category="top-rated"
|
||||
/>
|
||||
|
||||
<TrendingGrid
|
||||
title="Upcoming"
|
||||
movieEntries={upcomingMovieEntries}
|
||||
tvEntries={[]}
|
||||
isLoading={upcomingMovies.isLoading}
|
||||
category="upcoming"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<TrendingGrid
|
||||
title="Upcoming"
|
||||
movieEntries={upcomingMovieEntries}
|
||||
tvEntries={[]}
|
||||
isLoading={upcomingMovies.isLoading}
|
||||
category="upcoming"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user