Director field, search, and collection improvements

Backend: Added director column to Entry model, set during creation and
refresh. Maintenance endpoint to scan/fix missing directors. Reverted
expensive credit JOIN in getAllEntries.

Frontend: @director: search prefix for Library and Watchlist. Director
rendered on EntryDetailsPage via useEntryCredits. Fixed home page cards
to link directly to EntryDetailsPage when entry is in library. Added
TmdbCastsPage for TMDB cast browsing. Persisted collection sort order
and gray-out-unseen toggle. Tooltip component now theme-aware.
This commit is contained in:
X4Lo committed 2026-06-18 20:09:11 +01:00
1 parent 8671184dc5
commit 5a0328a17f
16 files changed
+1679 -629

No files matched your search

+92 -55
View File
@@ -1,21 +1,26 @@
import { useState, useEffect } from 'react';
import { useParams, Link, useNavigate } from 'react-router-dom';
import { useEntry, useEntrySeasons, useRefreshEntry } from '@/hooks/useEntries';
import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
import { useCollections } from '@/hooks/useCollections';
import { useLibraryStore } from '@/stores/useLibraryStore';
import { useCommandPaletteStore } from '@/stores/useCommandPaletteStore';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Separator } from '@/components/ui/separator';
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
import { useState, useEffect } from "react";
import { useParams, Link, useNavigate } from "react-router-dom";
import {
useEntry,
useEntrySeasons,
useRefreshEntry,
useEntryCredits,
} from "@/hooks/useEntries";
import { useEntrySeenByEntry, useDeleteEntrySeen } from "@/hooks/useEntrySeen";
import { useCollections } from "@/hooks/useCollections";
import { useLibraryStore } from "@/stores/useLibraryStore";
import { useCommandPaletteStore } from "@/stores/useCommandPaletteStore";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
} from "@/components/ui/dropdown-menu";
import {
Heart,
MoreHorizontal,
@@ -29,25 +34,25 @@ import {
History,
Trash2,
ExternalLink,
} from 'lucide-react';
} from "lucide-react";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from '@/components/ui/tooltip';
import { CastList } from '@/components/entries/CastList';
import { SeasonsContainer } from '@/components/entries/SeasonsContainer';
import { StreamingSection } from '@/components/streaming/StreamingSection';
} from "@/components/ui/tooltip";
import { CastList } from "@/components/entries/CastList";
import { SeasonsContainer } from "@/components/entries/SeasonsContainer";
import { StreamingSection } from "@/components/streaming/StreamingSection";
// EpisodeWatchHistory is available for future use
import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog';
import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog';
import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog';
import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog';
import { RatingDialog } from '@/components/dialogs/RatingDialog';
import { MovieWatchHistoryDialog } from '@/components/dialogs/MovieWatchHistoryDialog';
import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog';
import { EntryDetailsSkeleton } from '@/components/skeletons/PageSkeletons';
import { EntrySettingsDialog } from "@/components/dialogs/EntrySettingsDialog";
import { EntrySeenDialog } from "@/components/dialogs/EntrySeenDialog";
import { EntryMediaDialog } from "@/components/dialogs/EntryMediaDialog";
import { AddEntryToCollectionDialog } from "@/components/dialogs/AddEntryToCollectionDialog";
import { RatingDialog } from "@/components/dialogs/RatingDialog";
import { MovieWatchHistoryDialog } from "@/components/dialogs/MovieWatchHistoryDialog";
import { ConfirmDialog } from "@/components/dialogs/ConfirmDialog";
import { EntryDetailsSkeleton } from "@/components/skeletons/PageSkeletons";
import {
getPosterUrl,
getBackdropUrl,
@@ -55,9 +60,9 @@ import {
getYear,
formatRuntime,
formatDate,
} from '@/lib/media-utils';
import { useUpdateEntry, useDeleteEntry } from '@/hooks/useEntries';
import type { Collection, Entry } from '@/types';
} from "@/lib/media-utils";
import { useUpdateEntry, useDeleteEntry } from "@/hooks/useEntries";
import type { Collection, Entry } from "@/types";
export function EntryDetailsPage() {
const { id } = useParams<{ id: string }>();
@@ -65,6 +70,7 @@ export function EntryDetailsPage() {
const navigate = useNavigate();
const { data: entry, isLoading } = useEntry(entryId);
const { data: seasons } = useEntrySeasons(entryId);
const { data: allCredits = [] } = useEntryCredits(entryId);
const { data: watchHistory = [] } = useEntrySeenByEntry(entryId);
const updateEntry = useUpdateEntry();
const refreshEntry = useRefreshEntry();
@@ -73,9 +79,10 @@ export function EntryDetailsPage() {
// Merge library entry with detail entry so we get both library flags AND full details (credits, etc.)
const libraryEntry = useLibraryStore((s) => s.entries.get(entryId));
const displayEntry = libraryEntry && entry
? { ...libraryEntry, ...entry, isInLibrary: true }
: entry || libraryEntry;
const displayEntry =
libraryEntry && entry
? { ...libraryEntry, ...entry, isInLibrary: true }
: entry || libraryEntry;
const [showSettings, setShowSettings] = useState(false);
const [showSeenDialog, setShowSeenDialog] = useState(false);
@@ -92,7 +99,7 @@ export function EntryDetailsPage() {
addRecentlyViewed({
id: `lib-${entryId}`,
title: displayEntry.title,
type: displayEntry.is_tvseries ? 'tv' : 'movie',
type: displayEntry.is_tvseries ? "tv" : "movie",
poster_path: displayEntry.poster_path,
libraryId: entryId,
tmdbId: displayEntry.entryIds?.tmdb_id ?? undefined,
@@ -105,10 +112,13 @@ export function EntryDetailsPage() {
}
const e = displayEntry;
// Use useEntryCredits (allCredits) which includes both cast AND crew (director).
// e.credits from useEntry is a limited preview (10 items).
const credits = allCredits.length > 0 ? allCredits : e.credits || [];
const backdrop = getBackdropUrl(e);
const poster = getPosterUrl(e);
const director = e.credits?.find(
(c) => c.cast_type === 'crew' && c.job === 'Director'
const director = credits.find(
(c) => c.cast_type === "crew" && c.job === "Director",
);
const toggleFavorite = () => {
@@ -152,16 +162,23 @@ export function EntryDetailsPage() {
Rate this
</DropdownMenuItem>
{!e.is_tvseries && (
<DropdownMenuItem onClick={() => setShowWatchHistoryDialog(true)}>
<DropdownMenuItem
onClick={() => setShowWatchHistoryDialog(true)}
>
<History className="mr-2 h-4 w-4" />
Watch History
</DropdownMenuItem>
)}
<DropdownMenuSeparator />
{/* Organize */}
<DropdownMenuItem onClick={toggleFavorite} disabled={updateEntry.isPending}>
<Heart className={`mr-2 h-4 w-4 ${e.favorit ? 'fill-current' : ''}`} />
{e.favorit ? 'Unfavorite' : 'Favorite'}
<DropdownMenuItem
onClick={toggleFavorite}
disabled={updateEntry.isPending}
>
<Heart
className={`mr-2 h-4 w-4 ${e.favorit ? "fill-current" : ""}`}
/>
{e.favorit ? "Unfavorite" : "Favorite"}
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setShowCollectionDialog(true)}>
<FolderPlus className="mr-2 h-4 w-4" />
@@ -173,13 +190,18 @@ export function EntryDetailsPage() {
}
>
<EyeOff className="mr-2 h-4 w-4" />
{e.hidden ? 'Unhide' : 'Hide'}
{e.hidden ? "Unhide" : "Hide"}
</DropdownMenuItem>
<DropdownMenuSeparator />
{/* Manage */}
<DropdownMenuItem onClick={() => refreshEntry.mutate(e.id)} disabled={refreshEntry.isPending}>
<RefreshCw className={`mr-2 h-4 w-4 ${refreshEntry.isPending ? 'animate-spin' : ''}`} />
{refreshEntry.isPending ? 'Refreshing...' : 'Refresh details'}
<DropdownMenuItem
onClick={() => refreshEntry.mutate(e.id)}
disabled={refreshEntry.isPending}
>
<RefreshCw
className={`mr-2 h-4 w-4 ${refreshEntry.isPending ? "animate-spin" : ""}`}
/>
{refreshEntry.isPending ? "Refreshing..." : "Refresh details"}
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setShowMediaDialog(true)}>
<ImageIcon className="mr-2 h-4 w-4" />
@@ -218,7 +240,7 @@ export function EntryDetailsPage() {
<div className="flex items-center justify-center gap-3 mt-3">
{e.entryIds.tmdb_id && (
<a
href={`https://www.themoviedb.org/${e.is_tvseries ? 'tv' : 'movie'}/${e.entryIds.tmdb_id}`}
href={`https://www.themoviedb.org/${e.is_tvseries ? "tv" : "movie"}/${e.entryIds.tmdb_id}`}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
@@ -249,7 +271,7 @@ export function EntryDetailsPage() {
<h1 className="text-3xl font-bold leading-tight">{e.title}</h1>
{director?.people?.name && (
<p className="text-sm text-muted-foreground">
by{' '}
by{" "}
<Link
to={`/people/${director.people_id}`}
className="font-medium text-foreground hover:underline"
@@ -331,8 +353,14 @@ export function EntryDetailsPage() {
{e.genres && e.genres.length > 0 && (
<div className="flex flex-wrap gap-1.5">
{e.genres.map((g) => (
<Link key={g.id} to={`/library?genre=${encodeURIComponent(g.name)}`}>
<Badge variant="outline" className="text-xs cursor-pointer hover:bg-accent transition-colors">
<Link
key={g.id}
to={`/library?genre=${encodeURIComponent(g.name)}`}
>
<Badge
variant="outline"
className="text-xs cursor-pointer hover:bg-accent transition-colors"
>
{g.name}
</Badge>
</Link>
@@ -385,16 +413,20 @@ export function EntryDetailsPage() {
disabled={updateEntry.isPending}
className={`inline-flex items-center gap-1 rounded-full border px-3 py-1 text-sm font-medium transition-colors ${
e.favorit
? 'bg-yellow-500/15 border-yellow-500/30 text-yellow-600 dark:text-yellow-400 hover:bg-yellow-500/25'
: 'border-dashed border-border text-muted-foreground hover:border-yellow-500/40 hover:text-yellow-500'
? "bg-yellow-500/15 border-yellow-500/30 text-yellow-600 dark:text-yellow-400 hover:bg-yellow-500/25"
: "border-dashed border-border text-muted-foreground hover:border-yellow-500/40 hover:text-yellow-500"
}`}
>
<Star className={`h-3.5 w-3.5 ${e.favorit ? 'fill-yellow-400 text-yellow-400' : ''}`} />
<Star
className={`h-3.5 w-3.5 ${e.favorit ? "fill-yellow-400 text-yellow-400" : ""}`}
/>
Favorit
</button>
</TooltipTrigger>
<TooltipContent>
<p>{e.favorit ? 'Remove from favorites' : 'Add to favorites'}</p>
<p>
{e.favorit ? "Remove from favorites" : "Add to favorites"}
</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
@@ -414,10 +446,14 @@ export function EntryDetailsPage() {
{/* Streaming player */}
<StreamingSection entry={e} seasons={seasons} />
{e.credits && e.credits.length > 0 && (
{credits.length > 0 && (
<>
<Separator />
<CastList credits={e.credits} entryId={e.id} isTvSeries={e.is_tvseries} />
<CastList
credits={credits}
entryId={e.id}
isTvSeries={e.is_tvseries}
/>
</>
)}
@@ -503,7 +539,7 @@ export function EntryDetailsPage() {
variant="destructive"
onConfirm={() => {
deleteEntry.mutate(e.id, {
onSuccess: () => navigate('/library'),
onSuccess: () => navigate("/library"),
});
setShowDeleteConfirm(false);
}}
@@ -517,7 +553,7 @@ function EntryCollectionsSection({ entryId }: { entryId: number }) {
const { data: allCollections = [], isLoading } = useCollections();
const collections = allCollections.filter((col: Collection) =>
col.entries?.some((e: Entry) => e.id === entryId)
col.entries?.some((e: Entry) => e.id === entryId),
);
if (isLoading || collections.length === 0) return null;
@@ -549,7 +585,8 @@ function EntryCollectionsSection({ entryId }: { entryId: number }) {
</p>
{col.entries && (
<p className="text-xs text-white/70 mt-0.5">
{col.entries.length} {col.entries.length === 1 ? 'title' : 'titles'}
{col.entries.length}{" "}
{col.entries.length === 1 ? "title" : "titles"}
</p>
)}
</div>