941 lines
26 KiB
TypeScript
941 lines
26 KiB
TypeScript
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
|
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
|
import Box from "@mui/material/Box";
|
|
import Chip from "@mui/material/Chip";
|
|
import CircularProgress from "@mui/material/CircularProgress";
|
|
import Divider from "@mui/material/Divider";
|
|
import MenuItem from "@mui/material/MenuItem";
|
|
import TextField from "@mui/material/TextField";
|
|
import Typography from "@mui/material/Typography";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { motion } from "motion/react";
|
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
import { Card } from "@/components/card/card";
|
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
|
import ItemHeader from "@/components/itemHeader";
|
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
|
import { getRuntimeCompact, getRuntimeMusic } from "@/utils/date/time";
|
|
import useDefaultSeason from "@/utils/hooks/useDefaultSeason";
|
|
import "./series.scss";
|
|
|
|
import { createFileRoute, Link, useNavigate } from "@tanstack/react-router";
|
|
import LikeButton from "@/components/buttons/likeButton";
|
|
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
|
import PlayButton from "@/components/buttons/playButton";
|
|
import TrailerButton from "@/components/buttons/trailerButton";
|
|
import IconLink from "@/components/iconLink";
|
|
import ShowMoreText from "@/components/showMoreText";
|
|
import EpisodeSkeleton from "@/components/skeleton/episode";
|
|
import { SeasonSelectorSkeleton } from "@/components/skeleton/seasonSelector";
|
|
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
|
import { useCentralStore } from "@/utils/store/central";
|
|
|
|
const getEpisodeDateString = (date: Date) => {
|
|
const formatter = new Intl.DateTimeFormat(navigator.language ?? "en-US", {
|
|
dateStyle: "full",
|
|
});
|
|
return formatter.format(date).toString();
|
|
};
|
|
|
|
export const Route = createFileRoute("/_api/series/$id")({
|
|
component: SeriesTitlePage,
|
|
});
|
|
|
|
function SeriesTitlePage() {
|
|
const { id } = Route.useParams();
|
|
|
|
const api = Route.useRouteContext().api;
|
|
|
|
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
|
|
|
const user = useCentralStore((s) => s.currentUser);
|
|
|
|
const item = useQuery({
|
|
queryKey: ["item", id],
|
|
queryFn: async () => {
|
|
if (!api) return null;
|
|
const result = await getUserLibraryApi(api).getItem({
|
|
userId: user?.Id,
|
|
itemId: id,
|
|
});
|
|
return result.data;
|
|
},
|
|
enabled: !!user?.Id,
|
|
networkMode: "always",
|
|
refetchOnWindowFocus: true,
|
|
});
|
|
|
|
const similarItems = useQuery({
|
|
queryKey: ["item", id, "similarItem"],
|
|
queryFn: async () => {
|
|
if (!api) return null;
|
|
const result = await getLibraryApi(api).getSimilarShows({
|
|
userId: user?.Id,
|
|
itemId: id,
|
|
limit: 16,
|
|
});
|
|
return result.data;
|
|
},
|
|
});
|
|
|
|
const seasons = useQuery({
|
|
queryKey: ["item", id, "seasons"],
|
|
queryFn: async () => {
|
|
if (!api) return null;
|
|
const result = await getTvShowsApi(api).getSeasons({
|
|
userId: user?.Id,
|
|
seriesId: id,
|
|
isMissing: false,
|
|
});
|
|
return result.data;
|
|
},
|
|
});
|
|
|
|
const [backdropImage, setBackdropImage] = useState<SeriesBackdropImage>(
|
|
() => {
|
|
const url = sessionStorage.getItem(`backdrop-${item.data?.Id}`);
|
|
const key = sessionStorage.getItem(`backdrop-${item.data?.Id}-key`);
|
|
return { url, key };
|
|
},
|
|
);
|
|
const [_backdropImageLoaded, setBackdropImageLoaded] = useState(false);
|
|
|
|
const [currentSeason, setCurrentSeason] = useDefaultSeason(
|
|
seasons,
|
|
item.data?.Id,
|
|
);
|
|
|
|
const currentSeasonNumber = Number(currentSeason);
|
|
|
|
const currentSeasonItem = useQuery({
|
|
queryKey: ["item", id, "season", currentSeason],
|
|
queryFn: async () => {
|
|
if (!api) return null;
|
|
const result = await getUserLibraryApi(api).getItem({
|
|
userId: user?.Id,
|
|
itemId: seasons.data?.Items?.[Number(currentSeason)].Id ?? "",
|
|
});
|
|
return result.data;
|
|
},
|
|
enabled: seasons.isSuccess,
|
|
networkMode: "always",
|
|
refetchOnWindowFocus: true,
|
|
});
|
|
|
|
const episodes = useQuery({
|
|
queryKey: ["item", id, "season", currentSeason, "episodes"],
|
|
queryFn: async () => {
|
|
if (!api) return null;
|
|
const result = await getTvShowsApi(api).getEpisodes({
|
|
userId: user?.Id,
|
|
seriesId: item.data?.Id ?? "",
|
|
seasonId: seasons.data?.Items?.[Number(currentSeason)].Id,
|
|
fields: [ItemFields.Overview],
|
|
isMissing: false,
|
|
});
|
|
return result.data;
|
|
},
|
|
enabled: seasons.isSuccess,
|
|
networkMode: "always",
|
|
refetchOnWindowFocus: true,
|
|
});
|
|
|
|
const specialFeatures = useQuery({
|
|
queryKey: ["item", id, "specialFeatures"],
|
|
queryFn: async () => {
|
|
if (!api) return null;
|
|
const result = await getUserLibraryApi(api).getSpecialFeatures({
|
|
itemId: item.data?.Id ?? "",
|
|
userId: user?.Id,
|
|
});
|
|
return result.data;
|
|
},
|
|
enabled: item.isSuccess,
|
|
});
|
|
|
|
const directors = useMemo(() => {
|
|
return item.data?.People?.filter((itm) => itm.Type === "Director") ?? [];
|
|
}, [item.data?.Id]);
|
|
const writers = useMemo(() => {
|
|
return item.data?.People?.filter((itm) => itm.Type === "Writer") ?? [];
|
|
}, [item.data?.Id]);
|
|
const actors = useMemo(() => {
|
|
return item.data?.People?.filter((itm) => itm.Type === "Actor") ?? [];
|
|
}, [item.data?.Id]);
|
|
const producers = useMemo(() => {
|
|
return item.data?.People?.filter((itm) => itm.Type === "Producer") ?? [];
|
|
}, [item.data?.Id]);
|
|
|
|
const lastBackdropHashRef = useRef<string | undefined>(undefined);
|
|
|
|
useEffect(() => {
|
|
if (api && currentSeasonItem.isSuccess && item.isSuccess) {
|
|
if (
|
|
currentSeasonItem.isSuccess &&
|
|
(currentSeasonItem.data?.BackdropImageTags?.length ?? 0) > 0
|
|
) {
|
|
sessionStorage.setItem(
|
|
`backdrop-${item.data?.Id}`,
|
|
getImageUrlsApi(api).getItemImageUrlById(
|
|
currentSeasonItem.data?.Id ?? "",
|
|
"Backdrop",
|
|
{
|
|
tag: currentSeasonItem.data?.BackdropImageTags?.[0],
|
|
},
|
|
),
|
|
);
|
|
sessionStorage.setItem(
|
|
`backdrop-${item.data?.Id}-key`,
|
|
currentSeasonItem.data?.BackdropImageTags?.[0] ?? "",
|
|
);
|
|
setBackdropImage({
|
|
url: getImageUrlsApi(api).getItemImageUrlById(
|
|
currentSeasonItem.data?.Id ?? "",
|
|
"Backdrop",
|
|
{
|
|
tag: currentSeasonItem.data?.BackdropImageTags?.[0],
|
|
},
|
|
),
|
|
key: currentSeasonItem.data?.BackdropImageTags?.[0],
|
|
});
|
|
const seasonBackdropTag =
|
|
currentSeasonItem.data?.BackdropImageTags?.[0];
|
|
const seasonBackdropHash =
|
|
currentSeasonItem.data?.ImageBlurHashes?.Backdrop?.[
|
|
seasonBackdropTag ?? ""
|
|
] ?? "";
|
|
|
|
if (lastBackdropHashRef.current !== seasonBackdropHash) {
|
|
setBackdrop(seasonBackdropHash);
|
|
lastBackdropHashRef.current = seasonBackdropHash;
|
|
}
|
|
setBackdropImageLoaded(false);
|
|
} else if (
|
|
item.isSuccess &&
|
|
(item.data?.BackdropImageTags?.length ?? 0) > 0
|
|
) {
|
|
sessionStorage.setItem(
|
|
`backdrop-${item.data?.Id}`,
|
|
getImageUrlsApi(api).getItemImageUrlById(
|
|
item.data?.Id ?? "",
|
|
"Backdrop",
|
|
{
|
|
tag: item.data?.BackdropImageTags?.[0],
|
|
},
|
|
),
|
|
);
|
|
sessionStorage.setItem(
|
|
`backdrop-${item.data?.Id}-key`,
|
|
item.data?.BackdropImageTags?.[0] ?? "",
|
|
);
|
|
if (backdropImage.key !== item.data?.BackdropImageTags?.[0]) {
|
|
setBackdropImageLoaded(false); // Reset Backdrop image load status if previous image is diff then new image
|
|
}
|
|
setBackdropImage({
|
|
url: getImageUrlsApi(api).getItemImageUrlById(
|
|
item.data?.Id ?? "",
|
|
"Backdrop",
|
|
{
|
|
tag: item.data?.BackdropImageTags?.[0],
|
|
},
|
|
),
|
|
key: item.data?.BackdropImageTags?.[0],
|
|
});
|
|
const seriesBackdropTag = item.data?.BackdropImageTags?.[0];
|
|
const seriesBackdropHash =
|
|
item.data?.ImageBlurHashes?.Backdrop?.[seriesBackdropTag ?? ""] ?? "";
|
|
|
|
if (lastBackdropHashRef.current !== seriesBackdropHash) {
|
|
setBackdrop(seriesBackdropHash);
|
|
lastBackdropHashRef.current = seriesBackdropHash;
|
|
}
|
|
}
|
|
}
|
|
}, [
|
|
api,
|
|
currentSeasonItem.data,
|
|
currentSeasonItem.isSuccess,
|
|
item.data,
|
|
item.isSuccess,
|
|
setBackdrop,
|
|
backdropImage.key,
|
|
]);
|
|
|
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
// Parallax handled within ItemBackdrop to avoid hydration issues.
|
|
|
|
const navigate = useNavigate();
|
|
|
|
if (item.isPending || similarItems.isPending) {
|
|
return (
|
|
<Box
|
|
sx={{
|
|
width: "100%",
|
|
height: "100vh",
|
|
display: "flex",
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
}}
|
|
>
|
|
<CircularProgress />
|
|
</Box>
|
|
);
|
|
}
|
|
|
|
if (item.isSuccess && item.data) {
|
|
return (
|
|
<motion.div
|
|
key={id}
|
|
initial={{
|
|
opacity: 0,
|
|
}}
|
|
animate={{
|
|
opacity: 1,
|
|
}}
|
|
transition={{
|
|
duration: 0.25,
|
|
ease: "easeInOut",
|
|
}}
|
|
className="scrollY padded-top flex flex-column item item-series"
|
|
ref={containerRef}
|
|
>
|
|
<ItemHeader
|
|
item={item.data}
|
|
api={api}
|
|
scrollTargetRef={containerRef}
|
|
backdropSrc={backdropImage.url}
|
|
>
|
|
<div className="item-hero-buttons-container">
|
|
<div
|
|
className="flex flex-row"
|
|
style={{
|
|
width: "100%",
|
|
}}
|
|
>
|
|
<PlayButton
|
|
item={item.data}
|
|
itemType={BaseItemKind.Series}
|
|
userId={user?.Id}
|
|
buttonProps={{
|
|
fullWidth: true,
|
|
}}
|
|
/>
|
|
</div>
|
|
<div className="flex flex-row" style={{ gap: "1em" }}>
|
|
{item.data.RemoteTrailers && (
|
|
<TrailerButton
|
|
trailerItem={item.data.RemoteTrailers}
|
|
disabled={item.data.RemoteTrailers?.length === 0}
|
|
/>
|
|
)}
|
|
<LikeButton
|
|
itemName={item.data.Name}
|
|
itemId={item.data.Id}
|
|
queryKey={["item", id]}
|
|
isFavorite={item.data.UserData?.IsFavorite}
|
|
userId={user?.Id}
|
|
/>
|
|
<MarkPlayedButton
|
|
itemName={item.data.Name}
|
|
itemId={item.data.Id}
|
|
queryKey={["item", id]}
|
|
isPlayed={item.data.UserData?.Played}
|
|
userId={user?.Id}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</ItemHeader>
|
|
<div className="item-detail">
|
|
<div style={{ width: "100%" }}>
|
|
{(item.data.Taglines?.length ?? 0) > 0 && (
|
|
<Typography variant="h5" mb={2}>
|
|
{item.data.Taglines?.[0]}
|
|
</Typography>
|
|
)}
|
|
<ShowMoreText
|
|
content={item.data.Overview ?? ""}
|
|
collapsedLines={4}
|
|
/>
|
|
<div
|
|
style={{
|
|
display: "flex",
|
|
gap: "0.6em",
|
|
alignSelf: "end",
|
|
}}
|
|
>
|
|
{item.data.ExternalUrls?.map(
|
|
(url) =>
|
|
url.Url &&
|
|
url.Name && (
|
|
<IconLink key={url.Url} url={url.Url} name={url.Name} />
|
|
),
|
|
)}
|
|
</div>
|
|
</div>
|
|
<div
|
|
style={{
|
|
width: "100%",
|
|
}}
|
|
>
|
|
<div className="item-detail-cast">
|
|
{actors?.length > 0 && (
|
|
<div className="item-detail-cast-container">
|
|
<Typography variant="h6" className="item-detail-cast-title">
|
|
Actors
|
|
</Typography>
|
|
<div className="item-detail-cast-grid">
|
|
{actors.map((actor) => (
|
|
<Link
|
|
className="item-detail-cast-card"
|
|
key={actor.Id}
|
|
to="/person/$id"
|
|
params={{
|
|
id: actor.Id ?? "",
|
|
}}
|
|
>
|
|
{actor.PrimaryImageTag ? (
|
|
<img
|
|
alt={actor.Name ?? ""}
|
|
src={
|
|
api &&
|
|
getImageUrlsApi(api).getItemImageUrlById(
|
|
actor.Id ?? "",
|
|
"Primary",
|
|
{
|
|
quality: 80,
|
|
fillWidth: 200,
|
|
fillHeight: 200,
|
|
},
|
|
)
|
|
}
|
|
className="item-detail-cast-card-image"
|
|
/>
|
|
) : (
|
|
<div className="item-detail-cast-card-icon">
|
|
{getTypeIcon("Person")}
|
|
</div>
|
|
)}
|
|
<div className="item-detail-cast-card-text">
|
|
<Typography variant="subtitle1">
|
|
{actor.Name}
|
|
</Typography>
|
|
<Typography
|
|
variant="subtitle2"
|
|
style={{
|
|
opacity: 0.5,
|
|
}}
|
|
>
|
|
{actor.Role}
|
|
</Typography>
|
|
</div>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)}
|
|
{writers.length > 0 && (
|
|
<div className="item-detail-cast-container">
|
|
<Typography variant="h6" className="item-detail-cast-title">
|
|
Writers
|
|
</Typography>
|
|
<div className="item-detail-cast-grid">
|
|
{writers.map((actor) => (
|
|
<Link
|
|
className="item-detail-cast-card"
|
|
key={actor.Id}
|
|
to="/person/$id"
|
|
params={{
|
|
id: actor.Id ?? "",
|
|
}}
|
|
>
|
|
{actor.PrimaryImageTag ? (
|
|
<img
|
|
alt={actor.Name ?? ""}
|
|
src={
|
|
api &&
|
|
getImageUrlsApi(api).getItemImageUrlById(
|
|
actor.Id ?? "",
|
|
"Primary",
|
|
{
|
|
quality: 80,
|
|
fillWidth: 200,
|
|
fillHeight: 200,
|
|
},
|
|
)
|
|
}
|
|
className="item-detail-cast-card-image"
|
|
/>
|
|
) : (
|
|
<div className="item-detail-cast-card-icon">
|
|
{getTypeIcon("Person")}
|
|
</div>
|
|
)}
|
|
<div className="item-detail-cast-card-text">
|
|
<Typography variant="subtitle1">
|
|
{actor.Name}
|
|
</Typography>
|
|
<Typography
|
|
variant="subtitle2"
|
|
style={{
|
|
opacity: 0.5,
|
|
}}
|
|
>
|
|
{actor.Role}
|
|
</Typography>
|
|
</div>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)}
|
|
{directors.length > 0 && (
|
|
<div className="item-detail-cast-container">
|
|
<Typography variant="h6" className="item-detail-cast-title">
|
|
Directors
|
|
</Typography>
|
|
<div className="item-detail-cast-grid">
|
|
{directors.map((actor) => (
|
|
<Link
|
|
className="item-detail-cast-card"
|
|
key={actor.Id}
|
|
to="/person/$id"
|
|
params={{
|
|
id: actor.Id ?? "",
|
|
}}
|
|
>
|
|
{actor.PrimaryImageTag ? (
|
|
<img
|
|
alt={actor.Name ?? ""}
|
|
src={
|
|
api &&
|
|
getImageUrlsApi(api).getItemImageUrlById(
|
|
actor.Id ?? "",
|
|
"Primary",
|
|
{
|
|
quality: 80,
|
|
fillWidth: 200,
|
|
fillHeight: 200,
|
|
},
|
|
)
|
|
}
|
|
className="item-detail-cast-card-image"
|
|
/>
|
|
) : (
|
|
<div className="item-detail-cast-card-icon">
|
|
{getTypeIcon("Person")}
|
|
</div>
|
|
)}
|
|
<div className="item-detail-cast-card-text">
|
|
<Typography variant="subtitle1">
|
|
{actor.Name}
|
|
</Typography>
|
|
<Typography
|
|
variant="subtitle2"
|
|
style={{
|
|
opacity: 0.5,
|
|
}}
|
|
>
|
|
{actor.Role}
|
|
</Typography>
|
|
</div>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)}
|
|
{producers.length > 0 && (
|
|
<div className="item-detail-cast-container">
|
|
<Typography variant="h6" className="item-detail-cast-title">
|
|
Producers
|
|
</Typography>
|
|
<div className="item-detail-cast-grid">
|
|
{producers.map((actor) => (
|
|
<Link
|
|
className="item-detail-cast-card"
|
|
key={actor.Id}
|
|
to="/person/$id"
|
|
params={{
|
|
id: actor.Id ?? "",
|
|
}}
|
|
>
|
|
{actor.PrimaryImageTag ? (
|
|
<img
|
|
alt={actor.Name ?? ""}
|
|
src={
|
|
api &&
|
|
getImageUrlsApi(api).getItemImageUrlById(
|
|
actor.Id ?? "",
|
|
"Primary",
|
|
{
|
|
quality: 80,
|
|
fillWidth: 200,
|
|
fillHeight: 200,
|
|
},
|
|
)
|
|
}
|
|
className="item-detail-cast-card-image"
|
|
/>
|
|
) : (
|
|
<div className="item-detail-cast-card-icon">
|
|
{getTypeIcon("Person")}
|
|
</div>
|
|
)}
|
|
<div className="item-detail-cast-card-text">
|
|
<Typography variant="subtitle1">
|
|
{actor.Name}
|
|
</Typography>
|
|
<Typography
|
|
variant="subtitle2"
|
|
style={{
|
|
opacity: 0.5,
|
|
}}
|
|
>
|
|
{actor.Role}
|
|
</Typography>
|
|
</div>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{seasons.isPending ? (
|
|
<SeasonSelectorSkeleton />
|
|
) : (
|
|
<div className="item-series-seasons-container">
|
|
<div
|
|
style={{
|
|
display: "flex",
|
|
width: "100%",
|
|
alignItems: "center",
|
|
justifyContent: "space-between",
|
|
paddingBottom: " 0.5em",
|
|
}}
|
|
>
|
|
<div
|
|
style={{
|
|
display: "flex",
|
|
gap: "1em",
|
|
}}
|
|
>
|
|
<Typography variant="h5">
|
|
{seasons.data?.Items?.[Number(currentSeason)]?.Name}
|
|
</Typography>
|
|
<Chip
|
|
label={
|
|
episodes.isPending ? (
|
|
<CircularProgress
|
|
size={20}
|
|
style={{
|
|
display: "flex",
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
}}
|
|
/>
|
|
) : (
|
|
episodes.data?.TotalRecordCount
|
|
)
|
|
}
|
|
/>
|
|
</div>
|
|
<div
|
|
style={{
|
|
display: "flex",
|
|
gap: "0.75em",
|
|
}}
|
|
>
|
|
{currentSeasonItem.isSuccess && (
|
|
<LikeButton
|
|
itemId={currentSeasonItem.data?.Id}
|
|
isFavorite={currentSeasonItem.data?.UserData?.IsFavorite}
|
|
queryKey={["item", id]}
|
|
userId={user?.Id}
|
|
itemName={currentSeasonItem.data?.Name}
|
|
/>
|
|
)}
|
|
{currentSeasonItem.isSuccess && (
|
|
<MarkPlayedButton
|
|
itemId={currentSeasonItem.data?.Id}
|
|
isPlayed={currentSeasonItem.data?.UserData?.Played}
|
|
queryKey={["item", id]}
|
|
userId={user?.Id}
|
|
itemName={currentSeasonItem.data?.Name}
|
|
/>
|
|
)}
|
|
<TextField
|
|
value={currentSeasonNumber}
|
|
onChange={(e) => {
|
|
const seasonIndex = Number(e.target.value);
|
|
if (
|
|
!Number.isNaN(seasonIndex) &&
|
|
Number.isFinite(seasonIndex)
|
|
) {
|
|
setCurrentSeason(seasonIndex);
|
|
sessionStorage.setItem(
|
|
`season-${item.data?.Id}`,
|
|
seasonIndex.toString(),
|
|
);
|
|
}
|
|
}}
|
|
select
|
|
SelectProps={{
|
|
MenuProps: {
|
|
disableScrollLock: true,
|
|
},
|
|
}}
|
|
size="small"
|
|
>
|
|
{seasons.data?.Items?.map((season, index) => {
|
|
return (
|
|
<MenuItem key={season.Id} value={index}>
|
|
{season.Name}
|
|
</MenuItem>
|
|
);
|
|
})}
|
|
</TextField>
|
|
</div>
|
|
</div>
|
|
<Divider />
|
|
<div className="item-detail-episode-container">
|
|
{episodes.isPending ? (
|
|
<EpisodeSkeleton />
|
|
) : (
|
|
episodes.data?.Items?.map((episode) => {
|
|
return (
|
|
<motion.div
|
|
key={episode.Id}
|
|
onClick={() =>
|
|
navigate({
|
|
to: "/episode/$id",
|
|
params: { id: episode.Id ?? "" },
|
|
})
|
|
}
|
|
initial={{
|
|
transform: "translateY(10px)",
|
|
opacity: 0,
|
|
}}
|
|
whileInView={{
|
|
opacity: 1,
|
|
transform: "translateY(0px)",
|
|
}}
|
|
viewport={{
|
|
once: true,
|
|
}}
|
|
transition={{
|
|
duration: 0.2,
|
|
ease: "backInOut",
|
|
}}
|
|
style={{
|
|
width: "100%",
|
|
}}
|
|
className="item-detail-episode"
|
|
>
|
|
<Typography variant="subtitle1" textAlign="center">
|
|
{episode.IndexNumberEnd
|
|
? `${episode.IndexNumber} / ${episode.IndexNumberEnd}`
|
|
: (episode.IndexNumber ?? 0)}
|
|
</Typography>
|
|
<div
|
|
className={
|
|
episode.UserData?.Played
|
|
? "item-detail-episode-image-container watched"
|
|
: "item-detail-episode-image-container"
|
|
}
|
|
>
|
|
<div className="item-detail-episode-image-overlay">
|
|
<PlayButton
|
|
item={episode}
|
|
itemType={BaseItemKind.Episode}
|
|
userId={user?.Id}
|
|
size="medium"
|
|
buttonProps={{
|
|
//@ts-expect-error
|
|
color: "white",
|
|
style: {
|
|
color: "black ",
|
|
},
|
|
}}
|
|
iconOnly
|
|
/>
|
|
</div>
|
|
<div className="item-detail-episode-image-icon-container">
|
|
<span className="material-symbols-rounded item-detail-episode-image-icon">
|
|
tv_gen
|
|
</span>
|
|
</div>
|
|
<img
|
|
alt={episode.Name ?? ""}
|
|
src={
|
|
api &&
|
|
getImageUrlsApi(api).getItemImageUrlById(
|
|
episode.Id ?? "",
|
|
"Primary",
|
|
{
|
|
tag: episode.ImageTags?.Primary,
|
|
fillHeight: 300,
|
|
},
|
|
)
|
|
}
|
|
className="item-detail-episode-image"
|
|
onLoad={(e) => {
|
|
e.currentTarget.style.opacity = "1";
|
|
}}
|
|
/>
|
|
{(episode.UserData?.PlaybackPositionTicks ?? 0) > 0 && (
|
|
<div className="card-progress-container">
|
|
<div
|
|
className="card-progress"
|
|
style={{
|
|
width: `${episode.UserData?.PlayedPercentage}%`,
|
|
}}
|
|
/>
|
|
</div>
|
|
)}
|
|
</div>
|
|
<div className="item-detail-episode-info">
|
|
<Typography variant="subtitle1">
|
|
{episode.Name}
|
|
</Typography>
|
|
<div
|
|
className="flex flex-row flex-align-center"
|
|
style={{
|
|
gap: "0.5em",
|
|
}}
|
|
>
|
|
{episode.PremiereDate && (
|
|
<Chip
|
|
variant="filled"
|
|
label={getEpisodeDateString(
|
|
new Date(episode.PremiereDate),
|
|
)}
|
|
size="small"
|
|
/>
|
|
)}
|
|
<Typography variant="caption">
|
|
{getRuntimeCompact(episode.RunTimeTicks ?? 0)}
|
|
</Typography>
|
|
</div>
|
|
<Typography
|
|
variant="caption"
|
|
style={{
|
|
display: "-webkit-box",
|
|
textOverflow: "ellipsis",
|
|
overflow: "hidden",
|
|
WebkitLineClamp: 2,
|
|
WebkitBoxOrient: "vertical",
|
|
width: "100%",
|
|
opacity: 0.7,
|
|
}}
|
|
>
|
|
{episode.Overview}
|
|
</Typography>
|
|
</div>
|
|
<div className="item-detail-episode-buttons">
|
|
<LikeButton
|
|
itemId={episode.Id}
|
|
itemName={episode.Name}
|
|
isFavorite={episode.UserData?.IsFavorite}
|
|
queryKey={["item", id]}
|
|
userId={user?.Id}
|
|
/>
|
|
<MarkPlayedButton
|
|
itemId={episode.Id}
|
|
itemName={episode.Name}
|
|
isPlayed={episode.UserData?.Played}
|
|
queryKey={["item", id]}
|
|
userId={user?.Id}
|
|
/>
|
|
</div>
|
|
</motion.div>
|
|
);
|
|
})
|
|
)}
|
|
</div>
|
|
</div>
|
|
)}
|
|
{specialFeatures.isSuccess &&
|
|
(specialFeatures.data?.length ?? 0) > 0 && (
|
|
<CardScroller
|
|
title="Special Features"
|
|
displayCards={7}
|
|
disableDecoration
|
|
>
|
|
{specialFeatures.data?.map((special) => {
|
|
return (
|
|
<Card
|
|
key={special.Id}
|
|
item={special}
|
|
seriesId={special.SeriesId}
|
|
cardTitle={special.Name}
|
|
imageType="Primary"
|
|
cardCaption={getRuntimeMusic(special.RunTimeTicks ?? 0)}
|
|
cardType="portrait"
|
|
queryKey={["item", id, "similarItem"]}
|
|
userId={user?.Id}
|
|
onClick={() => {}}
|
|
/>
|
|
);
|
|
})}
|
|
</CardScroller>
|
|
)}
|
|
{(similarItems.data?.TotalRecordCount ?? 0) > 0 && (
|
|
<CardScroller
|
|
title="You might also like"
|
|
displayCards={7}
|
|
disableDecoration
|
|
>
|
|
{similarItems.data?.Items?.map((similar) => {
|
|
return (
|
|
<Card
|
|
key={similar.Id}
|
|
item={similar}
|
|
seriesId={similar.SeriesId}
|
|
cardTitle={
|
|
similar.Type === BaseItemKind.Episode
|
|
? similar.SeriesName
|
|
: similar.Name
|
|
}
|
|
imageType={"Primary"}
|
|
cardCaption={
|
|
similar.Type === BaseItemKind.Episode
|
|
? `S${similar.ParentIndexNumber}:E${similar.IndexNumber} - ${similar.Name}`
|
|
: similar.Type === BaseItemKind.Series
|
|
? `${similar.ProductionYear} - ${
|
|
similar.EndDate
|
|
? new Date(similar.EndDate).toLocaleString([], {
|
|
year: "numeric",
|
|
})
|
|
: "Present"
|
|
}`
|
|
: similar.ProductionYear
|
|
}
|
|
cardType={
|
|
similar.Type === BaseItemKind.MusicAlbum ||
|
|
similar.Type === BaseItemKind.Audio
|
|
? "square"
|
|
: "portrait"
|
|
}
|
|
queryKey={["item", id, "similarItem"]}
|
|
userId={user?.Id}
|
|
/>
|
|
);
|
|
})}
|
|
</CardScroller>
|
|
)}
|
|
</motion.div>
|
|
);
|
|
}
|
|
if (item.isError || similarItems.isError) {
|
|
return <ErrorNotice />;
|
|
}
|
|
}
|
|
|
|
export default SeriesTitlePage;
|