Fix collection images and entry settings toggles

- Show the uploaded backdrop on the collection details page; it only
  looked at the TMDB backdrop and ignored the collection's media
- Fall back to the first entry's poster for collections without a poster
  on both the collections grid and the details page
- Read the live entry from the library store in EntrySettingsDialog so
  toggles reflect the new value instead of a stale prop snapshot
This commit is contained in:
X4Lo committed 2026-11-03 16:25:12 +00:00
1 parent a9e4eea856
commit 72600cbc5d
4 files changed
+73 -21

No files matched your search

@@ -7,8 +7,10 @@ import {
useRemoveEntryFromCollection,
} from "@/hooks/useCollections";
import { EntryLibraryGrid } from "@/components/entries/EntryLibraryGrid";
import { getCollectionPosterUrl, getBackdropUrl } from "@/lib/media-utils";
import { getTmdbImageUrl } from "@/lib/api";
import {
getCollectionDisplayBackdropUrl,
getCollectionDisplayPosterUrl,
} from "@/lib/collection-media";
import { Skeleton } from "@/components/ui/skeleton";
import { Button } from "@/components/ui/button";
import {
@@ -101,21 +103,11 @@ export function CollectionDetailsPage() {
});
}, [entries, sortField, sortDir]);
// Fallback backdrop: use first entry's backdrop if collection has none
const backdropUrl = useMemo(() => {
if (collection?.backdrop_path)
return getTmdbImageUrl(collection.backdrop_path, "w1280");
// Try to find a backdrop from one of the entries
const entryWithBackdrop = entries.find((e) => e.banner_path);
if (entryWithBackdrop?.banner_path)
return getTmdbImageUrl(entryWithBackdrop.banner_path, "w1280");
// Try entry medias
for (const e of entries) {
const url = getBackdropUrl(e);
if (url) return url;
}
return null;
}, [collection?.backdrop_path, entries]);
// Uploaded backdrop wins, then TMDB backdrop, then the first entry's backdrop
const backdropUrl = useMemo(
() => (collection ? getCollectionDisplayBackdropUrl(collection) : null),
[collection],
);
const handleSort = (field: CollectionSortField) => {
if (field === sortField) {
@@ -254,7 +246,7 @@ export function CollectionDetailsPage() {
<div className="absolute bottom-0 left-0 right-0 flex items-end p-6">
<div className="flex items-end gap-4">
<img
src={getCollectionPosterUrl(collection)}
src={getCollectionDisplayPosterUrl(collection)}
alt={collection.name}
className="h-32 w-auto rounded-lg shadow-lg sm:h-40"
/>