feat(frontend): fix hooks crash, persist library filters, improve UI
- Fix "rendered more hooks" crash in CollectionDetailsPage by moving all hooks before conditionals - Persist library search/filters only on back navigation using useNavigationType - Add resetAll() to useLibraryFiltersStore - Move sort toolbar to hero bottom-right in CollectionDetailsPage - Fall back to entry backdrops when collection has none - Show full cast in TmdbPreviewPage matching EntryDetailsPage layout - Remove tagline/icons from TmdbPreviewPage to match in-library style - Lazy load people in local DB mode with infinite scroll - Move All/Favorite filter to right side in PeoplePage, always visible - Track dropdownOpen state in EntryCard to fix menu close flash Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
1 parent
ea143fb32a
commit
a42d4ee7d7
7 files changed
+325
-177
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { useState, useMemo, useCallback, useEffect, useRef } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { useSearchParams, useNavigationType } from 'react-router-dom';
|
||||
import { useLibrary } from '@/hooks/useEntries';
|
||||
import { useLibraryEntries } from '@/stores/useLibraryStore';
|
||||
import { useLibraryFiltersStore, defaultFilters } from '@/stores/useLibraryFiltersStore';
|
||||
@@ -52,6 +52,7 @@ const PAGE_SIZE = 28;
|
||||
export function LibraryPage() {
|
||||
const { isLoading } = useLibrary();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const navigationType = useNavigationType();
|
||||
|
||||
// Persistent filter state from store
|
||||
const activeTab = useLibraryFiltersStore((s) => s.activeTab);
|
||||
@@ -65,6 +66,7 @@ export function LibraryPage() {
|
||||
const filters = useLibraryFiltersStore((s) => s.filters);
|
||||
const setFilters = useLibraryFiltersStore((s) => s.setFilters);
|
||||
const clearFilters = useLibraryFiltersStore((s) => s.clearFilters);
|
||||
const resetAll = useLibraryFiltersStore((s) => s.resetAll);
|
||||
|
||||
const [debouncedSearch, setDebouncedSearch] = useState(search);
|
||||
const [debouncedFilters, setDebouncedFilters] = useState<Filters>(filters);
|
||||
@@ -73,6 +75,15 @@ export function LibraryPage() {
|
||||
|
||||
const allEntries = useLibraryEntries();
|
||||
|
||||
// Reset filters when navigating TO the library (not when pressing back)
|
||||
useEffect(() => {
|
||||
if (navigationType !== 'POP') {
|
||||
resetAll();
|
||||
}
|
||||
// Only run on mount
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
// Read URL query params once on mount
|
||||
useEffect(() => {
|
||||
if (filtersInitialized.current) return;
|
||||
|
||||
Reference in new issue
Block a user