fix: season episode dialog, mark season watched, episode 404 handling

Seasons Page:
- Episode watch button now opens EpisodeSeenEditDialog instead of
  directly marking as watched, allowing date/seen-with input
- Added "Mark Season as Watched" button that sequentially marks all
  unwatched episodes in the season

Episode Page:
- Fixed UI not updating after deleting the last episode seen record;
  the backend returns 404 when no records exist for an episode, which
  caused the query to error instead of resolving to an empty array.
  The API layer now catches 404 and returns [] gracefully.
This commit is contained in:
Mohammed Abad committed 2026-04-03 17:49:16 +01:00
1 parent 984e2c8b50
commit 6bff2055b4
12 files changed
+380 -90

No files matched your search

@@ -25,6 +25,7 @@ import {
Settings,
Star,
Loader2,
History,
} from 'lucide-react';
import {
Tooltip,
@@ -40,6 +41,7 @@ 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 { EntryDetailsSkeleton } from '@/components/skeletons/PageSkeletons';
import {
getPosterUrl,
@@ -73,6 +75,7 @@ export function EntryDetailsPage() {
const [showMediaDialog, setShowMediaDialog] = useState(false);
const [showCollectionDialog, setShowCollectionDialog] = useState(false);
const [showRatingDialog, setShowRatingDialog] = useState(false);
const [showWatchHistoryDialog, setShowWatchHistoryDialog] = useState(false);
if (isLoading || !displayEntry) {
return <EntryDetailsSkeleton />;
@@ -155,6 +158,12 @@ export function EntryDetailsPage() {
<Star className="mr-2 h-4 w-4" />
Rate this
</DropdownMenuItem>
{!e.is_tvseries && (
<DropdownMenuItem onClick={() => setShowWatchHistoryDialog(true)}>
<History className="mr-2 h-4 w-4" />
Watch History
</DropdownMenuItem>
)}
<DropdownMenuItem
onClick={() =>
updateEntry.mutate({ id: e.id, data: { hidden: !e.hidden } })
@@ -241,6 +250,31 @@ export function EntryDetailsPage() {
<span>{formatRuntime(e.runtime)}</span>
</>
)}
{!e.is_tvseries && watchHistory.length > 0 && (
<>
<span>•</span>
{watchHistory.length === 1 ? (
<span>seen {formatDate(watchHistory[0].date_seen)}</span>
) : (
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<span className="cursor-default underline decoration-dotted">
seen {watchHistory.length} times
</span>
</TooltipTrigger>
<TooltipContent>
<div className="space-y-0.5 text-xs">
{watchHistory.map((wh) => (
<p key={wh.id}>{formatDate(wh.date_seen)}</p>
))}
</div>
</TooltipContent>
</Tooltip>
</TooltipProvider>
)}
</>
)}
</div>
{/* Genres */}
@@ -372,6 +406,17 @@ export function EntryDetailsPage() {
entry={e}
/>
)}
{showWatchHistoryDialog && (
<MovieWatchHistoryDialog
open={showWatchHistoryDialog}
onOpenChange={setShowWatchHistoryDialog}
entryId={e.id}
watchHistory={watchHistory}
onDelete={(seenId) =>
deleteEntrySeen.mutate({ id: seenId, entryId: e.id })
}
/>
)}
</div>
);
}