Add toggle to gray out unseen entries in collections

Hide unseen button near sort controls applies grayscale + low opacity to
posters of entries that haven't been watched. Preference is persisted
per-collection via the existing sort store.
This commit is contained in:
X4Lo committed 2026-06-17 04:03:16 +01:00
1 parent e434dd3b5e
commit 3c29cf78ea
4 files changed
+91 -20

No files matched your search

@@ -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({
<img
src={posterUrl}
alt={title}
className="h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"
className={`h-full w-full object-cover transition-all duration-300 group-hover:scale-105 ${
grayOutUnseen && !isSeen ? "grayscale opacity-40" : ""
}`}
loading="lazy"
/>
@@ -182,7 +192,9 @@ export function EntryCard({
{/* Quick actions button – top right, shown on hover */}
{isInLibrary && (
<div className={`absolute right-2 top-2 z-20 transition-opacity ${dropdownOpen ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'}`}>
<div
className={`absolute right-2 top-2 z-20 transition-opacity ${dropdownOpen ? "opacity-100" : "opacity-0 group-hover:opacity-100"}`}
>
<DropdownMenu open={dropdownOpen} onOpenChange={setDropdownOpen}>
<DropdownMenuTrigger asChild>
<Button
@@ -1,6 +1,6 @@
import { useCallback, useRef, useEffect } from 'react';
import { EntryCard, EntryCardSkeleton } from './EntryCard';
import type { Entry } from '@/types';
import { useCallback, useRef, useEffect } from "react";
import { EntryCard, EntryCardSkeleton } from "./EntryCard";
import type { Entry } from "@/types";
interface EntryLibraryGridProps {
entries: Entry[];
@@ -9,6 +9,7 @@ interface EntryLibraryGridProps {
onLoadMore?: () => void;
collectionId?: number;
onRemoveFromCollection?: (entryId: number) => void;
grayOutUnseen?: boolean;
}
export function EntryLibraryGrid({
@@ -18,6 +19,7 @@ export function EntryLibraryGrid({
onLoadMore,
collectionId,
onRemoveFromCollection,
grayOutUnseen,
}: EntryLibraryGridProps) {
const observerRef = useRef<IntersectionObserver | null>(null);
@@ -32,7 +34,7 @@ export function EntryLibraryGrid({
});
if (node) observerRef.current.observe(node);
},
[isLoading, hasMore, onLoadMore]
[isLoading, hasMore, onLoadMore],
);
useEffect(() => {
@@ -66,7 +68,12 @@ export function EntryLibraryGrid({
className="animate-card-enter"
style={{ animationDelay: `${Math.min(index * 30, 300)}ms` }}
>
<EntryCard entry={entry} collectionId={collectionId} onRemoveFromCollection={onRemoveFromCollection} />
<EntryCard
entry={entry}
collectionId={collectionId}
onRemoveFromCollection={onRemoveFromCollection}
grayOutUnseen={grayOutUnseen}
/>
</div>
))}
{isLoading &&
@@ -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,9 +239,11 @@ export function CollectionDetailsPage() {
</div>
{/* Sort – bottom right */}
{entries.length > 1 && (
<div className="ml-auto flex items-center gap-1 self-end">
{(["order", "year", "title", "rating"] as const).map((field) => (
{entries.length > 1 && (
<>
{(["order", "year", "title", "rating"] as const).map(
(field) => (
<Button
key={field}
variant={sortField === field ? "secondary" : "ghost"}
@@ -253,9 +259,28 @@ export function CollectionDetailsPage() {
<ArrowDown className="h-3 w-3" />
))}
</Button>
))}
</div>
),
)}
<span className="mx-1 h-5 w-px bg-white/30" />
</>
)}
<Button
variant={hideUnseen ? "secondary" : "ghost"}
size="sm"
className="h-7 text-xs gap-1"
title={
hideUnseen ? "Show all entries" : "Gray out unseen entries"
}
onClick={() => setHideUnseen(collectionId, !hideUnseen)}
>
{hideUnseen ? (
<Eye className="h-3 w-3" />
) : (
<EyeOff className="h-3 w-3" />
)}
{hideUnseen ? "Show seen" : "Show all"}
</Button>
</div>
</div>
</div>
@@ -264,6 +289,7 @@ export function CollectionDetailsPage() {
entries={sortedEntries}
isLoading={false}
collectionId={collection.id}
grayOutUnseen={hideUnseen}
onRemoveFromCollection={(entryId) =>
removeEntryFromCollection.mutate({
collectionId: collection.id,
@@ -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<number, CollectionSortPref>;
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<CollectionSortState>()(
persist(
(set) => ({
@@ -23,12 +35,26 @@ export const useCollectionSortStore = create<CollectionSortState>()(
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",
},
),
);