diff --git a/react_frontend/src/components/entries/EntryCard.tsx b/react_frontend/src/components/entries/EntryCard.tsx index c40e8a0..fabb2a5 100644 --- a/react_frontend/src/components/entries/EntryCard.tsx +++ b/react_frontend/src/components/entries/EntryCard.tsx @@ -53,6 +53,8 @@ interface EntryCardProps { collectionId?: number; /** Callback to remove entry from collection */ onRemoveFromCollection?: (entryId: number) => void; + /** When true, apply grayscale + low opacity to posters of unseen entries */ + grayOutUnseen?: boolean; } export function EntryCard({ @@ -61,6 +63,7 @@ export function EntryCard({ showTypeBadge, collectionId, onRemoveFromCollection, + grayOutUnseen, }: EntryCardProps) { const [showConfirm, setShowConfirm] = useState(false); const [showRemoveCollectionConfirm, setShowRemoveCollectionConfirm] = @@ -90,6 +93,11 @@ export function EntryCard({ const isInLibrary = !!libraryEntry; const displayEntry = libraryEntry || entry; + // Determine if entry has been watched + const isSeen = !!( + displayEntry?.entrySeens?.length || displayEntry?.date_last_seen + ); + // Resolve display data const title = displayEntry?.title || tmdbEntry?.title || tmdbEntry?.name || "Untitled"; @@ -164,7 +172,9 @@ export function EntryCard({ {title} @@ -182,7 +192,9 @@ export function EntryCard({ {/* Quick actions button – top right, shown on hover */} {isInLibrary && ( -
+
))} {isLoading && diff --git a/react_frontend/src/pages/CollectionDetailsPage.tsx b/react_frontend/src/pages/CollectionDetailsPage.tsx index 81d506d..60a6cbf 100644 --- a/react_frontend/src/pages/CollectionDetailsPage.tsx +++ b/react_frontend/src/pages/CollectionDetailsPage.tsx @@ -25,6 +25,8 @@ import { Trash2, ArrowUp, ArrowDown, + Eye, + EyeOff, } from "lucide-react"; import { CollectionEditDialog } from "@/components/dialogs/CollectionEditDialog"; import { ConfirmDialog } from "@/components/dialogs/ConfirmDialog"; @@ -44,10 +46,12 @@ export function CollectionDetailsPage() { const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); const collectionSortPrefs = useCollectionSortStore((s) => s.prefs); const setSortPref = useCollectionSortStore((s) => s.setSort); + const setHideUnseen = useCollectionSortStore((s) => s.setHideUnseen); const collectionId = Number(id); const sortPref = collectionSortPrefs[collectionId]; const sortField: CollectionSortField = sortPref?.field ?? "order"; const sortDir: SortDir = sortPref?.dir ?? "asc"; + const hideUnseen = sortPref?.hideUnseen ?? false; const deleteCollection = useDeleteCollection(); const getCollectionParts = useGetCollectionParts(); const removeEntryFromCollection = useRemoveEntryFromCollection(); @@ -235,27 +239,48 @@ export function CollectionDetailsPage() {
{/* Sort – bottom right */} - {entries.length > 1 && ( -
- {(["order", "year", "title", "rating"] as const).map((field) => ( - - ))} -
- )} +
+ {entries.length > 1 && ( + <> + {(["order", "year", "title", "rating"] as const).map( + (field) => ( + + ), + )} + + + )} + +
@@ -264,6 +289,7 @@ export function CollectionDetailsPage() { entries={sortedEntries} isLoading={false} collectionId={collection.id} + grayOutUnseen={hideUnseen} onRemoveFromCollection={(entryId) => removeEntryFromCollection.mutate({ collectionId: collection.id, diff --git a/react_frontend/src/stores/useCollectionSortStore.ts b/react_frontend/src/stores/useCollectionSortStore.ts index 7996340..324e3f2 100644 --- a/react_frontend/src/stores/useCollectionSortStore.ts +++ b/react_frontend/src/stores/useCollectionSortStore.ts @@ -1,20 +1,32 @@ -import { create } from 'zustand'; -import { persist } from 'zustand/middleware'; +import { create } from "zustand"; +import { persist } from "zustand/middleware"; -export type CollectionSortField = 'order' | 'year' | 'title' | 'rating'; -export type SortDir = 'asc' | 'desc'; +export type CollectionSortField = "order" | "year" | "title" | "rating"; +export type SortDir = "asc" | "desc"; interface CollectionSortPref { field: CollectionSortField; dir: SortDir; + hideUnseen: boolean; } interface CollectionSortState { /** Map of collection id -> sort preference */ prefs: Record; - setSort: (collectionId: number, field: CollectionSortField, dir: SortDir) => void; + setSort: ( + collectionId: number, + field: CollectionSortField, + dir: SortDir, + ) => void; + setHideUnseen: (collectionId: number, hideUnseen: boolean) => void; } +const defaultPref: CollectionSortPref = { + field: "order", + dir: "asc", + hideUnseen: false, +}; + export const useCollectionSortStore = create()( persist( (set) => ({ @@ -23,12 +35,26 @@ export const useCollectionSortStore = create()( set((state) => ({ prefs: { ...state.prefs, - [collectionId]: { field, dir }, + [collectionId]: { + ...(state.prefs[collectionId] || defaultPref), + field, + dir, + }, + }, + })), + setHideUnseen: (collectionId, hideUnseen) => + set((state) => ({ + prefs: { + ...state.prefs, + [collectionId]: { + ...(state.prefs[collectionId] || defaultPref), + hideUnseen, + }, }, })), }), { - name: 'showy-collection-sort', - } - ) + name: "showy-collection-sort", + }, + ), );