refactor: cleanup item pages code and make them more perfomant
This commit is contained in:
10 files changed
+521
-1370
No files matched your search
@@ -359,11 +359,10 @@ const PlayButton = ({
|
||||
sx={sx}
|
||||
size={size}
|
||||
disabled={
|
||||
currentEpisode.isPending ||
|
||||
(itemType === BaseItemKind.Series &&
|
||||
(!currentEpisode.data ||
|
||||
!currentEpisode.data.Items ||
|
||||
currentEpisode.data.Items.length === 0))
|
||||
itemType === BaseItemKind.Series &&
|
||||
(!currentEpisode.data ||
|
||||
!currentEpisode.data.Items ||
|
||||
currentEpisode.data.Items.length === 0)
|
||||
}
|
||||
{...buttonProps}
|
||||
>
|
||||
|
||||
@@ -1,7 +1,319 @@
|
||||
import React from "react";
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import { green, red, yellow } from "@mui/material/colors";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import React, { type ReactNode, type RefObject } from "react";
|
||||
import { Blurhash } from "react-blurhash";
|
||||
import heroBg from "@/assets/herobg.png";
|
||||
import ultraHdIcon from "@/assets/icons/4k.svg";
|
||||
import dolbyAtmosIcon from "@/assets/icons/dolby-atmos.svg";
|
||||
import dolbyDigitalIcon from "@/assets/icons/dolby-digital.svg";
|
||||
import dolbyTrueHDIcon from "@/assets/icons/dolby-truehd.svg";
|
||||
import dolbyVisionIcon from "@/assets/icons/dolby-vision.svg";
|
||||
import dolbyVisionAtmosIcon from "@/assets/icons/dolby-vision-atmos.png";
|
||||
import dtsIcon from "@/assets/icons/dts.svg";
|
||||
import dtsHdMaIcon from "@/assets/icons/dts-hd-ma.svg";
|
||||
import hdIcon from "@/assets/icons/hd.svg";
|
||||
import hdrIcon from "@/assets/icons/hdr.svg";
|
||||
import hdr10Icon from "@/assets/icons/hdr10.svg";
|
||||
import hdr10PlusIcon from "@/assets/icons/hdr10-plus.svg";
|
||||
import sdIcon from "@/assets/icons/sd.svg";
|
||||
import sdrIcon from "@/assets/icons/sdr.svg";
|
||||
import ItemBackdrop from "@/components/itemBackdrop";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||
import "./itemHeader.scss";
|
||||
|
||||
const ItemHeader = () => {
|
||||
return <div>Item Header</div>;
|
||||
interface ItemHeaderProps {
|
||||
item: BaseItemDto;
|
||||
api: Api | undefined;
|
||||
mediaQualityInfo?: MediaQualityInfo;
|
||||
scrollTargetRef?: RefObject<HTMLDivElement | null>;
|
||||
children?: ReactNode;
|
||||
}
|
||||
|
||||
const ItemHeader = ({
|
||||
item,
|
||||
api,
|
||||
mediaQualityInfo,
|
||||
scrollTargetRef,
|
||||
children,
|
||||
}: ItemHeaderProps) => {
|
||||
return (
|
||||
<div className="item-hero">
|
||||
<div className="item-hero-backdrop-container">
|
||||
{scrollTargetRef && (
|
||||
<ItemBackdrop
|
||||
targetRef={scrollTargetRef}
|
||||
alt={item.Name ?? ""}
|
||||
backdropSrc={
|
||||
item.BackdropImageTags?.length
|
||||
? api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.Id ?? "",
|
||||
"Backdrop",
|
||||
{ tag: item.BackdropImageTags[0] },
|
||||
)
|
||||
: undefined
|
||||
}
|
||||
fallbackSrc={heroBg}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
className="item-hero-image-container"
|
||||
style={{
|
||||
aspectRatio: item.PrimaryImageAspectRatio ?? 1,
|
||||
}}
|
||||
>
|
||||
{item.ImageTags?.Primary ? (
|
||||
<div>
|
||||
<Blurhash
|
||||
hash={
|
||||
item.ImageBlurHashes?.Primary?.[item.ImageTags.Primary] ?? ""
|
||||
}
|
||||
className="item-hero-image-blurhash"
|
||||
/>
|
||||
<img
|
||||
alt={item.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.Id ?? "",
|
||||
"Primary",
|
||||
{
|
||||
quality: 90,
|
||||
tag: item.ImageTags.Primary,
|
||||
},
|
||||
)
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-image"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="item-hero-image-icon">
|
||||
{getTypeIcon(item.Type ?? "Movie")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="item-hero-detail flex flex-column">
|
||||
{item.ImageTags?.Logo ? (
|
||||
<img
|
||||
alt={item.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(item.Id ?? "", "Logo", {
|
||||
quality: 90,
|
||||
fillWidth: 592,
|
||||
fillHeight: 592,
|
||||
tag: item.ImageTags.Logo,
|
||||
})
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-logo"
|
||||
/>
|
||||
) : (
|
||||
<Typography mb={2} fontWeight={200} variant="h2">
|
||||
{item.Name}
|
||||
</Typography>
|
||||
)}
|
||||
<Stack
|
||||
direction="row"
|
||||
gap={2}
|
||||
justifyItems="flex-start"
|
||||
alignItems="center"
|
||||
>
|
||||
{mediaQualityInfo?.isUHD && (
|
||||
<img
|
||||
src={ultraHdIcon}
|
||||
alt="ultra hd"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isHD && (
|
||||
<img src={hdIcon} alt="hd" className="item-hero-mediaInfo badge" />
|
||||
)}
|
||||
{mediaQualityInfo?.isSD && (
|
||||
<img src={sdIcon} alt="sd" className="item-hero-mediaInfo badge" />
|
||||
)}
|
||||
{mediaQualityInfo?.isSDR && (
|
||||
<img
|
||||
src={sdrIcon}
|
||||
alt="sdr"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isHDR &&
|
||||
!mediaQualityInfo?.isHDR10 &&
|
||||
!mediaQualityInfo?.isHDR10Plus && (
|
||||
<img
|
||||
src={hdrIcon}
|
||||
alt="hdr"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isHDR10 && (
|
||||
<img
|
||||
src={hdr10Icon}
|
||||
alt="hdr10"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{item.PremiereDate && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{item.ProductionYear ?? ""}
|
||||
</Typography>
|
||||
)}
|
||||
{item.OfficialRating && (
|
||||
<Chip variant="filled" size="small" label={item.OfficialRating} />
|
||||
)}
|
||||
|
||||
{item.CommunityRating && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.25em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
// fontSize: "2.2em",
|
||||
color: yellow[400],
|
||||
}}
|
||||
>
|
||||
star
|
||||
</div>
|
||||
<Typography
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
>
|
||||
{Math.round(item.CommunityRating * 10) / 10}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
{item.CriticRating && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.25em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
color: item.CriticRating > 50 ? green[400] : red[400],
|
||||
}}
|
||||
>
|
||||
{item.CriticRating > 50 ? "thumb_up" : "thumb_down"}
|
||||
</div>
|
||||
<Typography
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
>
|
||||
{item.CriticRating}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{item.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{getRuntime(item.RunTimeTicks)}
|
||||
</Typography>
|
||||
)}
|
||||
{item.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{endsAt(
|
||||
item.RunTimeTicks - (item.UserData?.PlaybackPositionTicks ?? 0),
|
||||
)}
|
||||
</Typography>
|
||||
)}
|
||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||
{item.Genres?.slice(0, 4).join(" / ")}
|
||||
</Typography>
|
||||
</Stack>
|
||||
{mediaQualityInfo && (
|
||||
<Stack
|
||||
direction="row"
|
||||
gap={2}
|
||||
justifyItems="flex-start"
|
||||
alignItems="center"
|
||||
>
|
||||
{mediaQualityInfo?.isHDR10Plus && (
|
||||
<img
|
||||
src={hdr10PlusIcon}
|
||||
alt="hdr10+"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDts && (
|
||||
<img src={dtsIcon} alt="dts" className="item-hero-mediaInfo" />
|
||||
)}
|
||||
{mediaQualityInfo.isDtsHDMA && (
|
||||
<img
|
||||
src={dtsHdMaIcon}
|
||||
alt="dts-hd ma"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isAtmos && mediaQualityInfo.isDolbyVision && (
|
||||
<img
|
||||
src={dolbyVisionAtmosIcon}
|
||||
alt="dolby vision atmos"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isAtmos && !mediaQualityInfo.isDolbyVision && (
|
||||
<img
|
||||
src={dolbyAtmosIcon}
|
||||
alt="dolby atmos"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDolbyVision && !mediaQualityInfo.isAtmos && (
|
||||
<img
|
||||
src={dolbyVisionIcon}
|
||||
alt="dolby vision"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isTrueHD && (
|
||||
<img
|
||||
src={dolbyTrueHDIcon}
|
||||
alt="dolby truehd"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDD && (
|
||||
<img
|
||||
src={dolbyDigitalIcon}
|
||||
alt="dolby digital"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
</Stack>
|
||||
)}
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ItemHeader;
|
||||
@@ -0,0 +1,98 @@
|
||||
@import "../../styles/variables.scss";
|
||||
|
||||
$cardWidth: 18%;
|
||||
|
||||
.item-hero {
|
||||
height: 60vh;
|
||||
gap: 2em;
|
||||
row-gap: 1.2em;
|
||||
position: relative;
|
||||
align-items: flex-end;
|
||||
display: grid;
|
||||
grid-template-columns: $cardWidth 1fr;
|
||||
grid-template-rows: 1fr auto;
|
||||
&-image {
|
||||
opacity: 0;
|
||||
width: 100%;
|
||||
object-fit: contain;
|
||||
transition: opacity $transition-time-default;
|
||||
&-container {
|
||||
height: fit-content;
|
||||
max-height: 100%;
|
||||
overflow: hidden;
|
||||
border-radius: $border-radius-default;
|
||||
box-shadow: $shadow-card;
|
||||
flex-grow: 1;
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
&-blurhash {
|
||||
position: absolute !important;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
z-index: -1;
|
||||
}
|
||||
&-icon {
|
||||
background: linear-gradient(45deg, rgb(255 255 255 / 0.05), rgb(255 255 255 / 0.15));
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
.material-symbols-rounded{
|
||||
font-size: 4em;
|
||||
}
|
||||
}
|
||||
}
|
||||
&-logo {
|
||||
max-width: 34rem;
|
||||
max-height: 10rem;
|
||||
opacity: 0;
|
||||
transition: opacity $transition-time-default;
|
||||
object-position: bottom;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
&-detail {
|
||||
width: 100%;
|
||||
align-items: flex-start;
|
||||
gap: 0.2em;
|
||||
justify-content: end;
|
||||
}
|
||||
&-buttons {
|
||||
&-container {
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
grid-column: 1/3;
|
||||
display: grid;
|
||||
grid-template-columns: inherit;
|
||||
gap: 2em;
|
||||
}
|
||||
}
|
||||
&-backdrop {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
object-fit: cover;
|
||||
object-position: top;
|
||||
opacity: 0;
|
||||
transition: opacity $transition-time-default;
|
||||
&-container {
|
||||
filter: brightness(0.8);
|
||||
position: absolute;
|
||||
top: -4.4em;
|
||||
left: -$page-margin;
|
||||
width: 100vw;
|
||||
height: calc(54vh + 4.4em);
|
||||
z-index: -1;
|
||||
mask-image: linear-gradient(to top, transparent, black);
|
||||
-webkit-mask-image: linear-gradient(
|
||||
to top,
|
||||
transparent,
|
||||
black
|
||||
);
|
||||
}
|
||||
}
|
||||
& .play-button {
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
+12
-107
@@ -20,10 +20,10 @@ import React, {
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import { Blurhash } from "react-blurhash";
|
||||
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import { Card } from "@/components/card/card";
|
||||
import ItemHeader from "@/components/itemHeader";
|
||||
import { ArtistAlbum } from "@/components/layouts/artist/artistAlbum";
|
||||
import MusicTrack from "@/components/musicTrack";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
@@ -34,8 +34,6 @@ import "./artist.scss";
|
||||
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import IconLink from "@/components/iconLink";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
|
||||
|
||||
@@ -92,7 +90,7 @@ function ArtistTitlePage() {
|
||||
queryFn: async () => {
|
||||
if (!api) return null;
|
||||
const result = await getItemsApi(api).getItems({
|
||||
albumArtistIds: [item.data?.Id ?? ""],
|
||||
albumArtistIds: [id],
|
||||
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
||||
sortOrder: [SortOrder.Descending],
|
||||
recursive: true,
|
||||
@@ -102,7 +100,6 @@ function ArtistTitlePage() {
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: item.isSuccess && item.data?.Type === BaseItemKind.MusicArtist,
|
||||
});
|
||||
|
||||
const artistSongs = useQuery({
|
||||
@@ -111,7 +108,7 @@ function ArtistTitlePage() {
|
||||
if (!api) return null;
|
||||
|
||||
const result = await getItemsApi(api).getItems({
|
||||
artistIds: [item.data?.Id ?? ""],
|
||||
artistIds: [id],
|
||||
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
||||
sortOrder: [SortOrder.Ascending],
|
||||
recursive: true,
|
||||
@@ -121,7 +118,6 @@ function ArtistTitlePage() {
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: item.isSuccess && item.data?.Type === BaseItemKind.MusicArtist,
|
||||
});
|
||||
|
||||
const artistAppearances = useQuery({
|
||||
@@ -129,8 +125,8 @@ function ArtistTitlePage() {
|
||||
queryFn: async () => {
|
||||
if (!api) return null;
|
||||
const result = await getItemsApi(api).getItems({
|
||||
contributingArtistIds: [item.data?.Id ?? ""],
|
||||
excludeItemIds: [item.data?.Id ?? ""],
|
||||
contributingArtistIds: [id],
|
||||
excludeItemIds: [id],
|
||||
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
||||
sortOrder: [SortOrder.Descending],
|
||||
recursive: true,
|
||||
@@ -139,7 +135,6 @@ function ArtistTitlePage() {
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: item.isSuccess && item.data?.Type === BaseItemKind.MusicArtist,
|
||||
});
|
||||
|
||||
const artistTabs = [
|
||||
@@ -182,11 +177,6 @@ function ArtistTitlePage() {
|
||||
}, [item.isSuccess]);
|
||||
|
||||
const scrollTargetRef = useRef<HTMLDivElement | null>(null);
|
||||
const { scrollYProgress } = useScroll({
|
||||
target: scrollTargetRef,
|
||||
offset: ["start start", "60vh start"],
|
||||
});
|
||||
const parallax = useParallax(scrollYProgress, 50);
|
||||
|
||||
if (item.isPending) {
|
||||
return (
|
||||
@@ -220,97 +210,12 @@ function ArtistTitlePage() {
|
||||
className="scrollY item item-artist"
|
||||
>
|
||||
<div ref={scrollTargetRef} />
|
||||
<div className="item-hero flex flex-row">
|
||||
<div className="item-hero-backdrop-container">
|
||||
<motion.img
|
||||
alt={item.data?.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data?.Id ?? "",
|
||||
"Backdrop",
|
||||
{
|
||||
tag: item.data.BackdropImageTags?.[0],
|
||||
},
|
||||
)
|
||||
}
|
||||
className="item-hero-backdrop"
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
style={{
|
||||
y: parallax,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="item-hero-image-container"
|
||||
style={{
|
||||
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
||||
}}
|
||||
>
|
||||
{item.data.ImageTags?.Primary ? (
|
||||
<div>
|
||||
<Blurhash
|
||||
hash={
|
||||
item.data.ImageBlurHashes?.Primary?.[
|
||||
item.data.ImageTags.Primary
|
||||
] ?? ""
|
||||
}
|
||||
className="item-hero-image-blurhash"
|
||||
/>
|
||||
<img
|
||||
alt={item.data.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.Id ?? "",
|
||||
"Primary",
|
||||
{
|
||||
quality: 90,
|
||||
tag: item.data.ImageTags.Primary,
|
||||
},
|
||||
)
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-image"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="item-hero-image-icon">
|
||||
{getTypeIcon(item.data.Type ?? "MusicArtist")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="item-hero-detail flex flex-column">
|
||||
{item.data.ImageTags?.Logo ? (
|
||||
<img
|
||||
alt={item.data.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.Id ?? "",
|
||||
"Logo",
|
||||
{
|
||||
quality: 90,
|
||||
fillWidth: 592,
|
||||
fillHeight: 592,
|
||||
},
|
||||
)
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-logo"
|
||||
/>
|
||||
) : (
|
||||
<Typography variant="h2" fontWeight={200}>
|
||||
{item.data.Name}
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
<ItemHeader
|
||||
item={item.data}
|
||||
api={api}
|
||||
scrollTargetRef={scrollTargetRef}
|
||||
>
|
||||
<div className="item-hero-buttons-container">
|
||||
<LikeButton
|
||||
itemName={item.data.Name}
|
||||
itemId={item.data.Id}
|
||||
@@ -319,7 +224,7 @@ function ArtistTitlePage() {
|
||||
userId={user?.Id}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ItemHeader>
|
||||
<div className="item-detail">
|
||||
<div style={{ width: "100%", overflow: "hidden" }}>
|
||||
<ShowMoreText
|
||||
|
||||
+11
-221
@@ -7,31 +7,23 @@ import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-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 Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { motion, useScroll } from "motion/react";
|
||||
import { motion } from "motion/react";
|
||||
import React, { useLayoutEffect, useRef } from "react";
|
||||
import { Blurhash } from "react-blurhash";
|
||||
import heroBg from "@/assets/herobg.png";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
||||
import PlayButton from "@/components/buttons/playButton";
|
||||
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 ShowMoreText from "@/components/showMoreText";
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
import useParallax from "@/utils/hooks/useParallax";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import "./boxset.scss";
|
||||
|
||||
import { green, red, yellow } from "@mui/material/colors";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import IconLink from "@/components/iconLink";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
|
||||
@@ -66,13 +58,12 @@ function BoxSetTitlePage() {
|
||||
if (!api) return null;
|
||||
const result = await getItemsApi(api).getItems({
|
||||
userId: user?.Id,
|
||||
parentId: item.data?.Id,
|
||||
parentId: id,
|
||||
fields: [ItemFields.SeasonUserData, ItemFields.Overview],
|
||||
excludeLocationTypes: [LocationType.Virtual],
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: item.isSuccess,
|
||||
networkMode: "always",
|
||||
refetchOnWindowFocus: true,
|
||||
});
|
||||
@@ -80,15 +71,14 @@ function BoxSetTitlePage() {
|
||||
const similarItems = useQuery({
|
||||
queryKey: ["item", "similarItem", id],
|
||||
queryFn: async () => {
|
||||
if (!api || !item.data?.Id) return null;
|
||||
if (!api) return null;
|
||||
const result = await getLibraryApi(api).getSimilarItems({
|
||||
userId: user?.Id,
|
||||
itemId: item.data?.Id,
|
||||
itemId: id,
|
||||
limit: 16,
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: item.isSuccess,
|
||||
networkMode: "always",
|
||||
refetchOnWindowFocus: true,
|
||||
});
|
||||
@@ -114,11 +104,6 @@ function BoxSetTitlePage() {
|
||||
}, [item.isSuccess]);
|
||||
|
||||
const scrollTargetRef = useRef<HTMLDivElement | null>(null);
|
||||
const { scrollYProgress } = useScroll({
|
||||
target: scrollTargetRef,
|
||||
offset: ["start start", "60vh start"],
|
||||
});
|
||||
const parallax = useParallax(scrollYProgress, 50);
|
||||
|
||||
if (item.isPending || similarItems.isPending) {
|
||||
return (
|
||||
@@ -152,206 +137,11 @@ function BoxSetTitlePage() {
|
||||
className="scrollY item item-boxset padded-top"
|
||||
>
|
||||
<div ref={scrollTargetRef} />
|
||||
<div className="item-hero flex flex-row">
|
||||
<div className="item-hero-backdrop-container">
|
||||
{item.data.BackdropImageTags?.length ? (
|
||||
<motion.img
|
||||
alt={item.data.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.Id ?? "",
|
||||
"Backdrop",
|
||||
{
|
||||
tag: item.data.BackdropImageTags[0],
|
||||
},
|
||||
)
|
||||
}
|
||||
className="item-hero-backdrop"
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
style={{
|
||||
y: parallax,
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<motion.img
|
||||
alt={item.data.Name ?? ""}
|
||||
src={heroBg}
|
||||
className="item-hero-backdrop"
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
style={{
|
||||
y: parallax,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
className="item-hero-image-container"
|
||||
style={{
|
||||
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
||||
}}
|
||||
>
|
||||
{item.data.ImageTags?.Primary &&
|
||||
item.data.ImageBlurHashes?.Primary ? (
|
||||
<div>
|
||||
<Blurhash
|
||||
hash={
|
||||
item.data.ImageBlurHashes?.Primary?.[
|
||||
item.data.ImageTags.Primary
|
||||
]
|
||||
}
|
||||
className="item-hero-image-blurhash"
|
||||
/>
|
||||
<img
|
||||
alt={item.data.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.Id ?? "",
|
||||
"Primary",
|
||||
{
|
||||
quality: 90,
|
||||
tag: item.data.ImageTags.Primary,
|
||||
},
|
||||
)
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-image"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="item-hero-image-icon">
|
||||
{getTypeIcon(item.data.Type ?? "BoxSet")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="item-hero-detail">
|
||||
{item.data.ImageTags?.Logo ? (
|
||||
<img
|
||||
alt={item.data.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.Id ?? "",
|
||||
"Logo",
|
||||
{
|
||||
quality: 90,
|
||||
fillWidth: 592,
|
||||
fillHeight: 592,
|
||||
},
|
||||
)
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-logo"
|
||||
/>
|
||||
) : (
|
||||
<Typography variant="h2" fontWeight={200} mb={2}>
|
||||
{item.data.Name}
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
<Stack
|
||||
direction="row"
|
||||
gap={2}
|
||||
justifyItems="flex-start"
|
||||
alignItems="center"
|
||||
>
|
||||
{item.data.PremiereDate && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{item.data.ProductionYear ?? ""}
|
||||
</Typography>
|
||||
)}
|
||||
{item.data.OfficialRating && (
|
||||
<Chip
|
||||
variant="filled"
|
||||
size="small"
|
||||
label={item.data.OfficialRating}
|
||||
/>
|
||||
)}
|
||||
|
||||
{item.data.CommunityRating && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.25em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
// fontSize: "2.2em",
|
||||
color: yellow[400],
|
||||
}}
|
||||
>
|
||||
star
|
||||
</div>
|
||||
<Typography
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
>
|
||||
{Math.round(item.data.CommunityRating * 10) / 10}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
{item.data.CriticRating && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.25em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
color:
|
||||
item.data.CriticRating > 50 ? green[400] : red[400],
|
||||
}}
|
||||
>
|
||||
{item.data.CriticRating > 50 ? "thumb_up" : "thumb_down"}
|
||||
</div>
|
||||
<Typography
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
>
|
||||
{item.data.CriticRating}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{item.data.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{getRuntime(item.data.RunTimeTicks)}
|
||||
</Typography>
|
||||
)}
|
||||
{item.data.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{endsAt(
|
||||
item.data.RunTimeTicks -
|
||||
(item.data.UserData?.PlaybackPositionTicks ?? 0),
|
||||
)}
|
||||
</Typography>
|
||||
)}
|
||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||
{item.data.Genres?.slice(0, 4).join(" / ")}
|
||||
</Typography>
|
||||
</Stack>
|
||||
</div>
|
||||
<ItemHeader
|
||||
item={item.data}
|
||||
api={api}
|
||||
scrollTargetRef={scrollTargetRef}
|
||||
>
|
||||
<div className="item-hero-buttons-container flex flex-row">
|
||||
<div className="flex flex-row fullWidth">
|
||||
<PlayButton
|
||||
@@ -383,7 +173,7 @@ function BoxSetTitlePage() {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ItemHeader>
|
||||
<div
|
||||
className="item-detail"
|
||||
style={{
|
||||
|
||||
@@ -292,341 +292,12 @@ function EpisodeTitlePage() {
|
||||
className="scrollY padded-top flex flex-column item item-episode"
|
||||
ref={containerRef}
|
||||
>
|
||||
<div className="item-hero">
|
||||
<div className="item-hero-backdrop-container">
|
||||
{item.data.ParentBackdropImageTags?.length ? (
|
||||
<ItemBackdrop
|
||||
targetRef={containerRef}
|
||||
alt={item.data.Name ?? ""}
|
||||
backdropSrc={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.ParentBackdropItemId ?? "",
|
||||
"Backdrop",
|
||||
{ tag: item.data.ParentBackdropImageTags[0] },
|
||||
)
|
||||
}
|
||||
fallbackSrc={heroBg}
|
||||
className="item-hero-backdrop"
|
||||
/>
|
||||
) : (
|
||||
<ItemBackdrop
|
||||
targetRef={containerRef}
|
||||
alt={item.data.Name ?? ""}
|
||||
fallbackSrc={heroBg}
|
||||
className="item-hero-backdrop"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
className="item-hero-image-container"
|
||||
style={{
|
||||
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
||||
}}
|
||||
>
|
||||
{item.data.ImageTags?.Primary ? (
|
||||
<div>
|
||||
<Blurhash
|
||||
hash={
|
||||
item.data.ImageBlurHashes?.Primary?.[
|
||||
item.data.ImageTags.Primary
|
||||
] ?? ""
|
||||
}
|
||||
className="item-hero-image-blurhash"
|
||||
/>
|
||||
<img
|
||||
alt={item.data.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.Id ?? "",
|
||||
"Primary",
|
||||
{
|
||||
quality: 90,
|
||||
tag: item.data.ImageTags.Primary,
|
||||
},
|
||||
)
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-image"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="item-hero-image-icon">
|
||||
{getTypeIcon(item.data.Type ?? "Episode")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="item-hero-detail">
|
||||
<Typography
|
||||
variant="h2"
|
||||
fontWeight="200"
|
||||
mb={2}
|
||||
style={{
|
||||
textDecoration: "none",
|
||||
}}
|
||||
>
|
||||
<Link
|
||||
style={{ textDecoration: "none", color: "white" }}
|
||||
to="/series/$id"
|
||||
params={{ id: item.data.SeriesId ?? "" }}
|
||||
>
|
||||
{item.data.ParentLogoItemId ? (
|
||||
<img
|
||||
alt={item.data.SeriesName ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.ParentLogoItemId,
|
||||
"Logo",
|
||||
{
|
||||
quality: 90,
|
||||
fillWidth: 592,
|
||||
fillHeight: 592,
|
||||
},
|
||||
)
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-logo"
|
||||
/>
|
||||
) : (
|
||||
item.data.SeriesName
|
||||
)}
|
||||
</Link>
|
||||
</Typography>
|
||||
<Typography variant="h4" fontWeight={300} mb={2}>
|
||||
S{item.data.ParentIndexNumber ?? 0}:E
|
||||
{item.data.IndexNumberEnd
|
||||
? `${item.data.IndexNumber ?? 0} / ${
|
||||
item.data.IndexNumberEnd ?? 0
|
||||
}`
|
||||
: `${item.data.IndexNumber ?? 0}`}{" "}
|
||||
{item.data.Name}
|
||||
</Typography>
|
||||
|
||||
<Stack
|
||||
direction="row"
|
||||
gap={2}
|
||||
justifyItems="flex-start"
|
||||
alignItems="center"
|
||||
>
|
||||
{mediaQualityInfo?.isUHD && (
|
||||
<img
|
||||
src={ultraHdIcon}
|
||||
alt="ultra hd"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isHD && (
|
||||
<img
|
||||
src={hdIcon}
|
||||
alt="hd"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isSD && (
|
||||
<img
|
||||
src={sdIcon}
|
||||
alt="sd"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isSDR && (
|
||||
<img
|
||||
src={sdrIcon}
|
||||
alt="sdr"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isHDR &&
|
||||
!mediaQualityInfo?.isHDR10 &&
|
||||
!mediaQualityInfo?.isHDR10Plus && (
|
||||
<img
|
||||
src={hdrIcon}
|
||||
alt="hdr"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isHDR10 && (
|
||||
<img
|
||||
src={hdr10Icon}
|
||||
alt="hdr10"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{item.data.PremiereDate && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{item.data.ProductionYear ?? ""}
|
||||
</Typography>
|
||||
)}
|
||||
{item.data.OfficialRating && (
|
||||
<Chip
|
||||
variant="filled"
|
||||
size="small"
|
||||
label={item.data.OfficialRating}
|
||||
/>
|
||||
)}
|
||||
|
||||
{item.data.CommunityRating && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.25em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
// fontSize: "2.2em",
|
||||
color: yellow[400],
|
||||
}}
|
||||
>
|
||||
star
|
||||
</div>
|
||||
<Typography
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
>
|
||||
{Math.round(item.data.CommunityRating * 10) / 10}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
{item.data.CriticRating && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.25em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
color:
|
||||
item.data.CriticRating > 50 ? green[400] : red[400],
|
||||
}}
|
||||
>
|
||||
{item.data.CriticRating > 50 ? "thumb_up" : "thumb_down"}
|
||||
</div>
|
||||
<Typography
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
>
|
||||
{item.data.CriticRating}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{item.data.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{getRuntime(item.data.RunTimeTicks)}
|
||||
</Typography>
|
||||
)}
|
||||
{item.data.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{endsAt(
|
||||
item.data.RunTimeTicks -
|
||||
(item.data.UserData?.PlaybackPositionTicks ?? 0),
|
||||
)}
|
||||
</Typography>
|
||||
)}
|
||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||
{item.data.Genres?.slice(0, 4).join(" / ")}
|
||||
</Typography>
|
||||
</Stack>
|
||||
{mediaQualityInfo && (
|
||||
<Stack
|
||||
direction="row"
|
||||
gap={2}
|
||||
justifyItems="flex-start"
|
||||
alignItems="center"
|
||||
>
|
||||
{mediaQualityInfo?.isHDR10Plus && (
|
||||
<img
|
||||
src={hdr10PlusIcon}
|
||||
alt="hdr10+"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDts && (
|
||||
<img
|
||||
src={dtsIcon}
|
||||
alt="dts"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDtsHDMA && (
|
||||
<img
|
||||
src={dtsHdMaIcon}
|
||||
alt="dts-hd ma"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isAtmos && mediaQualityInfo.isDolbyVision && (
|
||||
<img
|
||||
src={dolbyVisionAtmosIcon}
|
||||
alt="dolby vision atmos"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isAtmos &&
|
||||
!mediaQualityInfo.isDolbyVision && (
|
||||
<img
|
||||
src={dolbyAtmosIcon}
|
||||
alt="dolby atmos"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDolbyVision &&
|
||||
!mediaQualityInfo.isAtmos && (
|
||||
<img
|
||||
src={dolbyVisionIcon}
|
||||
alt="dolby vision"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isTrueHD && (
|
||||
<img
|
||||
src={dolbyTrueHDIcon}
|
||||
alt="dolby truehd"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDD && (
|
||||
<img
|
||||
src={dolbyDigitalIcon}
|
||||
alt="dolby digital"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDDP && (
|
||||
<img
|
||||
src={dolbyDigitalPlusIcon}
|
||||
alt="dolby digital plus"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isIMAX && (
|
||||
<img
|
||||
src={imaxIcon}
|
||||
alt="imax"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
</Stack>
|
||||
)}
|
||||
</div>
|
||||
<ItemHeader
|
||||
item={item.data}
|
||||
api={api}
|
||||
mediaQualityInfo={mediaQualityInfo}
|
||||
scrollTargetRef={containerRef}
|
||||
>
|
||||
<div className="item-hero-buttons-container">
|
||||
<div className="flex flex-row">
|
||||
<PlayButton
|
||||
@@ -661,7 +332,7 @@ function EpisodeTitlePage() {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ItemHeader>
|
||||
<div className="item-detail">
|
||||
<div className="fullWidth">
|
||||
<ShowMoreText
|
||||
|
||||
+23
-368
@@ -3,42 +3,20 @@ import {
|
||||
MediaStreamType,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import { green, red, yellow } from "@mui/material/colors";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import TextField from "@mui/material/TextField";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
||||
import { motion } from "motion/react";
|
||||
import React, { useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||
import { Blurhash } from "react-blurhash";
|
||||
import heroBg from "@/assets/herobg.png";
|
||||
import { Card } from "@/components/card/card";
|
||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||
// import useParallax from "@/utils/hooks/useParallax";
|
||||
import ItemBackdrop from "@/components/itemBackdrop";
|
||||
import ItemHeader from "@/components/itemHeader";
|
||||
|
||||
import "./item.scss";
|
||||
|
||||
import { createFileRoute, Link } from "@tanstack/react-router";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import ultraHdIcon from "@/assets/icons/4k.svg";
|
||||
import dolbyAtmosIcon from "@/assets/icons/dolby-atmos.svg";
|
||||
import dolbyDigitalIcon from "@/assets/icons/dolby-digital.svg";
|
||||
import dolbyDigitalPlusIcon from "@/assets/icons/dolby-digital-plus.svg";
|
||||
import dolbyTrueHDIcon from "@/assets/icons/dolby-truehd.svg";
|
||||
import dolbyVisionIcon from "@/assets/icons/dolby-vision.svg";
|
||||
import dolbyVisionAtmosIcon from "@/assets/icons/dolby-vision-atmos.png";
|
||||
import dtsIcon from "@/assets/icons/dts.svg";
|
||||
import dtsHdMaIcon from "@/assets/icons/dts-hd-ma.svg";
|
||||
import hdIcon from "@/assets/icons/hd.svg";
|
||||
import hdrIcon from "@/assets/icons/hdr.svg";
|
||||
import hdr10Icon from "@/assets/icons/hdr10.svg";
|
||||
import hdr10PlusIcon from "@/assets/icons/hdr10-plus.svg";
|
||||
import imaxIcon from "@/assets/icons/imax.svg";
|
||||
import sdIcon from "@/assets/icons/sd.svg";
|
||||
import sdrIcon from "@/assets/icons/sdr.svg";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
||||
import PlayButton from "@/components/buttons/playButton";
|
||||
@@ -47,7 +25,6 @@ import IconLink from "@/components/iconLink";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import ItemSkeleton from "@/components/skeleton/item";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { getItemQueryOptions } from "@/utils/queries/items";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
@@ -60,9 +37,21 @@ export const Route = createFileRoute("/_api/item/$id")({
|
||||
// pendingMs: 5000,
|
||||
loader: async ({ context: { queryClient, api, user }, params }) => {
|
||||
if (!api || !user?.Id) return null;
|
||||
await queryClient.ensureQueryData(
|
||||
const itemPromise = queryClient.ensureQueryData(
|
||||
getItemQueryOptions(params.id, api, user?.Id),
|
||||
);
|
||||
queryClient.prefetchQuery({
|
||||
queryKey: ["item", params.id, "similarItem"],
|
||||
queryFn: async () =>
|
||||
(
|
||||
await getLibraryApi(api).getSimilarItems({
|
||||
userId: user?.Id,
|
||||
itemId: params.id,
|
||||
limit: 16,
|
||||
})
|
||||
).data,
|
||||
});
|
||||
await itemPromise;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -78,47 +67,12 @@ function ItemDetail() {
|
||||
const similarItems = useQuery({
|
||||
queryKey: ["item", id, "similarItem"],
|
||||
queryFn: async () => {
|
||||
if (!item.isSuccess) return null;
|
||||
if (!api || !user?.Id) return null;
|
||||
|
||||
if (!item.data?.Id) return null;
|
||||
if (item.data?.Type === "Movie") {
|
||||
return (
|
||||
await getLibraryApi(api).getSimilarMovies({
|
||||
userId: user?.Id,
|
||||
itemId: item.data.Id,
|
||||
limit: 16,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
if (item.data?.Type === "Series") {
|
||||
return (
|
||||
await getLibraryApi(api).getSimilarShows({
|
||||
userId: user?.Id,
|
||||
itemId: item.data.Id,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
if (item.data?.Type === "MusicAlbum") {
|
||||
return (
|
||||
await getLibraryApi(api).getSimilarAlbums({
|
||||
userId: user?.Id,
|
||||
itemId: item.data.Id,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
if (item.data?.Type === "MusicArtist") {
|
||||
return (
|
||||
await getLibraryApi(api).getSimilarArtists({
|
||||
userId: user?.Id,
|
||||
itemId: item.data.Id,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
return (
|
||||
await getLibraryApi(api).getSimilarItems({
|
||||
userId: user?.Id,
|
||||
itemId: item.data.Id,
|
||||
itemId: id,
|
||||
limit: 16,
|
||||
})
|
||||
).data;
|
||||
},
|
||||
@@ -311,311 +265,12 @@ function ItemDetail() {
|
||||
className="scrollY padded-top flex flex-column item item-default"
|
||||
ref={scrollTargetRef}
|
||||
>
|
||||
<div className="item-hero">
|
||||
<div className="item-hero-backdrop-container">
|
||||
<ItemBackdrop
|
||||
targetRef={scrollTargetRef}
|
||||
alt={item.data.Name ?? ""}
|
||||
backdropSrc={
|
||||
item.data.BackdropImageTags?.length
|
||||
? api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.Id ?? "",
|
||||
"Backdrop",
|
||||
{ tag: item.data.BackdropImageTags[0] },
|
||||
)
|
||||
: undefined
|
||||
}
|
||||
fallbackSrc={heroBg}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="item-hero-image-container"
|
||||
style={{
|
||||
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
||||
}}
|
||||
>
|
||||
{item.data.ImageTags?.Primary ? (
|
||||
<div>
|
||||
<Blurhash
|
||||
hash={
|
||||
item.data.ImageBlurHashes?.Primary?.[
|
||||
item.data.ImageTags.Primary
|
||||
] ?? ""
|
||||
}
|
||||
className="item-hero-image-blurhash"
|
||||
/>
|
||||
<img
|
||||
alt={item.data.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.Id ?? "",
|
||||
"Primary",
|
||||
{
|
||||
quality: 90,
|
||||
tag: item.data.ImageTags.Primary,
|
||||
},
|
||||
)
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-image"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="item-hero-image-icon">
|
||||
{getTypeIcon(item.data.Type ?? "Movie")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="item-hero-detail flex flex-column">
|
||||
{item.data.ImageTags?.Logo ? (
|
||||
<img
|
||||
alt={item.data.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.Id ?? "",
|
||||
"Logo",
|
||||
{
|
||||
quality: 90,
|
||||
fillWidth: 592,
|
||||
fillHeight: 592,
|
||||
tag: item.data.ImageTags.Logo,
|
||||
},
|
||||
)
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-logo"
|
||||
/>
|
||||
) : (
|
||||
<Typography mb={2} fontWeight={200} variant="h2">
|
||||
{item.data.Name}
|
||||
</Typography>
|
||||
)}
|
||||
<Stack
|
||||
direction="row"
|
||||
gap={2}
|
||||
justifyItems="flex-start"
|
||||
alignItems="center"
|
||||
>
|
||||
{mediaQualityInfo?.isUHD && (
|
||||
<img
|
||||
src={ultraHdIcon}
|
||||
alt="ultra hd"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isHD && (
|
||||
<img
|
||||
src={hdIcon}
|
||||
alt="hd"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isSD && (
|
||||
<img
|
||||
src={sdIcon}
|
||||
alt="sd"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isSDR && (
|
||||
<img
|
||||
src={sdrIcon}
|
||||
alt="sdr"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isHDR &&
|
||||
!mediaQualityInfo?.isHDR10 &&
|
||||
!mediaQualityInfo?.isHDR10Plus && (
|
||||
<img
|
||||
src={hdrIcon}
|
||||
alt="hdr"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo?.isHDR10 && (
|
||||
<img
|
||||
src={hdr10Icon}
|
||||
alt="hdr10"
|
||||
className="item-hero-mediaInfo badge"
|
||||
/>
|
||||
)}
|
||||
{item.data.PremiereDate && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{item.data.ProductionYear ?? ""}
|
||||
</Typography>
|
||||
)}
|
||||
{item.data.OfficialRating && (
|
||||
<Chip
|
||||
variant="filled"
|
||||
size="small"
|
||||
label={item.data.OfficialRating}
|
||||
/>
|
||||
)}
|
||||
|
||||
{item.data.CommunityRating && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.25em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
// fontSize: "2.2em",
|
||||
color: yellow[400],
|
||||
}}
|
||||
>
|
||||
star
|
||||
</div>
|
||||
<Typography
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
>
|
||||
{Math.round(item.data.CommunityRating * 10) / 10}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
{item.data.CriticRating && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.25em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
color:
|
||||
item.data.CriticRating > 50 ? green[400] : red[400],
|
||||
}}
|
||||
>
|
||||
{item.data.CriticRating > 50 ? "thumb_up" : "thumb_down"}
|
||||
</div>
|
||||
<Typography
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
>
|
||||
{item.data.CriticRating}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{item.data.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{getRuntime(item.data.RunTimeTicks)}
|
||||
</Typography>
|
||||
)}
|
||||
{item.data.RunTimeTicks && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{endsAt(
|
||||
item.data.RunTimeTicks -
|
||||
(item.data.UserData?.PlaybackPositionTicks ?? 0),
|
||||
)}
|
||||
</Typography>
|
||||
)}
|
||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||
{item.data.Genres?.slice(0, 4).join(" / ")}
|
||||
</Typography>
|
||||
</Stack>
|
||||
{mediaQualityInfo && (
|
||||
<Stack
|
||||
direction="row"
|
||||
gap={2}
|
||||
justifyItems="flex-start"
|
||||
alignItems="center"
|
||||
>
|
||||
{mediaQualityInfo?.isHDR10Plus && (
|
||||
<img
|
||||
src={hdr10PlusIcon}
|
||||
alt="hdr10+"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDts && (
|
||||
<img
|
||||
src={dtsIcon}
|
||||
alt="dts"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDtsHDMA && (
|
||||
<img
|
||||
src={dtsHdMaIcon}
|
||||
alt="dts-hd ma"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isAtmos && mediaQualityInfo.isDolbyVision && (
|
||||
<img
|
||||
src={dolbyVisionAtmosIcon}
|
||||
alt="dolby vision atmos"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isAtmos &&
|
||||
!mediaQualityInfo.isDolbyVision && (
|
||||
<img
|
||||
src={dolbyAtmosIcon}
|
||||
alt="dolby atmos"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDolbyVision &&
|
||||
!mediaQualityInfo.isAtmos && (
|
||||
<img
|
||||
src={dolbyVisionIcon}
|
||||
alt="dolby vision"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isTrueHD && (
|
||||
<img
|
||||
src={dolbyTrueHDIcon}
|
||||
alt="dolby truehd"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDD && (
|
||||
<img
|
||||
src={dolbyDigitalIcon}
|
||||
alt="dolby digital"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isDDP && (
|
||||
<img
|
||||
src={dolbyDigitalPlusIcon}
|
||||
alt="dolby digital plus"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
{mediaQualityInfo.isIMAX && (
|
||||
<img
|
||||
src={imaxIcon}
|
||||
alt="imax"
|
||||
className="item-hero-mediaInfo"
|
||||
/>
|
||||
)}
|
||||
</Stack>
|
||||
)}
|
||||
</div>
|
||||
<ItemHeader
|
||||
item={item.data}
|
||||
api={api}
|
||||
mediaQualityInfo={mediaQualityInfo}
|
||||
scrollTargetRef={scrollTargetRef}
|
||||
>
|
||||
<div className="item-hero-buttons-container">
|
||||
<div
|
||||
className="flex flex-row"
|
||||
@@ -659,7 +314,7 @@ function ItemDetail() {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ItemHeader>
|
||||
<div className="item-detail">
|
||||
<div style={{ width: "100%" }}>
|
||||
{(item.data.Taglines?.length ?? 0) > 0 && (
|
||||
|
||||
@@ -1,41 +1,32 @@
|
||||
import React, {
|
||||
useState,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
|
||||
import { BaseItemKind, LocationType } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import Box from "@mui/material/Box";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import Divider from "@mui/material/Divider";
|
||||
import Tab from "@mui/material/Tab";
|
||||
import Tabs from "@mui/material/Tabs";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
|
||||
import { BaseItemKind, LocationType } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
|
||||
import { Card } from "@/components/card/card";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { Blurhash } from "react-blurhash";
|
||||
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import React, {
|
||||
type ReactNode,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import { Card } from "@/components/card/card";
|
||||
import ItemHeader from "@/components/itemHeader";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
import meshBg from "@/assets/herobg.png";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import "./person.scss";
|
||||
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import IconLink from "@/components/iconLink";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
type TabPanelProps = {
|
||||
children: ReactNode;
|
||||
@@ -100,7 +91,6 @@ function PersonTitlePage() {
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: item.isSuccess && item.data?.Type === BaseItemKind.Person,
|
||||
networkMode: "always",
|
||||
});
|
||||
const personShows = useQuery({
|
||||
@@ -118,7 +108,6 @@ function PersonTitlePage() {
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: item.isSuccess && item.data?.Type === BaseItemKind.Person,
|
||||
networkMode: "always",
|
||||
});
|
||||
const personBooks = useQuery({
|
||||
@@ -136,7 +125,6 @@ function PersonTitlePage() {
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: item.isSuccess && item.data?.Type === BaseItemKind.Person,
|
||||
networkMode: "always",
|
||||
});
|
||||
const personPhotos = useQuery({
|
||||
@@ -153,7 +141,6 @@ function PersonTitlePage() {
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: item.isSuccess && item.data?.Type === BaseItemKind.Person,
|
||||
networkMode: "always",
|
||||
});
|
||||
const personEpisodes = useQuery({
|
||||
@@ -171,7 +158,6 @@ function PersonTitlePage() {
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: item.isSuccess && item.data?.Type === BaseItemKind.Person,
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
@@ -273,68 +259,20 @@ function PersonTitlePage() {
|
||||
className="scrollY padded-top item item-person flex flex-column"
|
||||
ref={pageRef}
|
||||
>
|
||||
<div className="item-hero">
|
||||
<div className="item-hero-backdrop-container">
|
||||
<img
|
||||
alt={item.data.Name ?? ""}
|
||||
src={meshBg}
|
||||
className="item-hero-backdrop"
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
/>
|
||||
<ItemHeader item={item.data} api={api}>
|
||||
<div className="item-hero-buttons-container flex flex-row">
|
||||
<div className="flex flex-row fullWidth" />
|
||||
<div className="flex flex-row" style={{ gap: "1em" }}>
|
||||
<LikeButton
|
||||
itemName={item.data.Name}
|
||||
itemId={item.data.Id}
|
||||
queryKey={["item", id]}
|
||||
isFavorite={item.data.UserData?.IsFavorite}
|
||||
userId={user?.Id}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="item-hero-image-container"
|
||||
style={{
|
||||
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
||||
}}
|
||||
>
|
||||
{item.data.ImageTags?.Primary && (
|
||||
<div>
|
||||
<Blurhash
|
||||
hash={
|
||||
item.data.ImageBlurHashes?.Primary?.[
|
||||
item.data.ImageTags.Primary
|
||||
] ?? ""
|
||||
}
|
||||
className="item-hero-image-blurhash"
|
||||
/>
|
||||
<img
|
||||
alt={item.data.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.Id ?? "",
|
||||
"Primary",
|
||||
{
|
||||
quality: 90,
|
||||
tag: item.data.ImageTags.Primary,
|
||||
},
|
||||
)
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-image"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="item-hero-detail flex flex-column">
|
||||
<Typography variant="h2" fontWeight={200} mb={2}>
|
||||
{item.data.Name}
|
||||
</Typography>
|
||||
|
||||
<LikeButton
|
||||
itemName={item.data.Name}
|
||||
itemId={item.data.Id}
|
||||
queryKey={["item", id]}
|
||||
isFavorite={item.data.UserData?.IsFavorite}
|
||||
userId={user?.Id}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ItemHeader>
|
||||
<div className="item-detail">
|
||||
<div style={{ width: "100%" }}>
|
||||
<ShowMoreText
|
||||
|
||||
@@ -5,32 +5,22 @@ 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 { green, red, yellow } from "@mui/material/colors";
|
||||
import Divider from "@mui/material/Divider";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import TextField from "@mui/material/TextField";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import { motion } from "motion/react";
|
||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Blurhash } from "react-blurhash";
|
||||
import { Card } from "@/components/card/card";
|
||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||
// import useParallax from "@/utils/hooks/useParallax";
|
||||
import ItemBackdrop from "@/components/itemBackdrop";
|
||||
import ItemHeader from "@/components/itemHeader";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import {
|
||||
endsAt,
|
||||
getRuntime,
|
||||
getRuntimeCompact,
|
||||
getRuntimeMusic,
|
||||
} from "@/utils/date/time";
|
||||
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 heroBg from "@/assets/herobg.png";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
||||
import PlayButton from "@/components/buttons/playButton";
|
||||
@@ -85,27 +75,24 @@ function SeriesTitlePage() {
|
||||
if (!api) return null;
|
||||
const result = await getLibraryApi(api).getSimilarShows({
|
||||
userId: user?.Id,
|
||||
itemId: item.data?.Id ?? "",
|
||||
itemId: id,
|
||||
limit: 16,
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: item.isSuccess,
|
||||
});
|
||||
|
||||
const seasons = useQuery({
|
||||
queryKey: ["item", id, "seasons"],
|
||||
queryFn: async () => {
|
||||
if (!api) return null;
|
||||
if (!item.data?.Id) return null;
|
||||
const result = await getTvShowsApi(api).getSeasons({
|
||||
userId: user?.Id,
|
||||
seriesId: item.data.Id,
|
||||
seriesId: id,
|
||||
isMissing: false,
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: item.isSuccess,
|
||||
});
|
||||
|
||||
const [backdropImage, setBackdropImage] = useState<SeriesBackdropImage>(
|
||||
@@ -115,7 +102,7 @@ function SeriesTitlePage() {
|
||||
return { url, key };
|
||||
},
|
||||
);
|
||||
const [backdropImageLoaded, setBackdropImageLoaded] = useState(false);
|
||||
const [_backdropImageLoaded, setBackdropImageLoaded] = useState(false);
|
||||
|
||||
const [currentSeason, setCurrentSeason] = useDefaultSeason(
|
||||
seasons,
|
||||
@@ -316,211 +303,7 @@ function SeriesTitlePage() {
|
||||
className="scrollY padded-top flex flex-column item item-series"
|
||||
ref={containerRef}
|
||||
>
|
||||
<div className="item-hero">
|
||||
<div className="item-hero-backdrop-container">
|
||||
<AnimatePresence mode="wait">
|
||||
{item.data.BackdropImageTags ? (
|
||||
<ItemBackdrop
|
||||
key={backdropImage.key}
|
||||
targetRef={containerRef}
|
||||
alt={item.data.Name ?? ""}
|
||||
backdropSrc={backdropImage.url ?? ""}
|
||||
fallbackSrc={heroBg}
|
||||
className="item-hero-backdrop"
|
||||
onLoad={() => {
|
||||
console.info("Image Loaded");
|
||||
setBackdropImageLoaded(true);
|
||||
}}
|
||||
motionProps={{
|
||||
initial: { opacity: 0 },
|
||||
animate: { opacity: backdropImageLoaded ? 1 : 0 },
|
||||
exit: { opacity: 0 },
|
||||
transition: { duration: 0.2 },
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<ItemBackdrop
|
||||
targetRef={containerRef}
|
||||
alt={item.data.Name ?? ""}
|
||||
fallbackSrc={heroBg}
|
||||
className="item-hero-backdrop"
|
||||
/>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
<div
|
||||
className="item-hero-image-container"
|
||||
style={{
|
||||
aspectRatio: item.data.PrimaryImageAspectRatio ?? 1,
|
||||
}}
|
||||
>
|
||||
{item.data.ImageTags?.Primary ? (
|
||||
<div>
|
||||
<Blurhash
|
||||
hash={
|
||||
item.data.ImageBlurHashes?.Primary?.[
|
||||
item.data.ImageTags.Primary
|
||||
] ?? ""
|
||||
}
|
||||
className="item-hero-image-blurhash"
|
||||
/>
|
||||
<img
|
||||
alt={item.data.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.Id ?? "",
|
||||
"Primary",
|
||||
{
|
||||
quality: 90,
|
||||
tag: item.data.ImageTags.Primary,
|
||||
},
|
||||
)
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-image"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="item-hero-image-icon">
|
||||
{getTypeIcon(item.data.Type ?? "Series")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="item-hero-detail">
|
||||
{item.data.ImageTags?.Logo ? (
|
||||
<img
|
||||
alt={item.data.Name ?? ""}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.Id ?? "",
|
||||
"Logo",
|
||||
{
|
||||
quality: 90,
|
||||
fillWidth: 592,
|
||||
fillHeight: 592,
|
||||
},
|
||||
)
|
||||
}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
className="item-hero-logo"
|
||||
/>
|
||||
) : (
|
||||
<Typography variant="h2" mb={2} fontWeight={200}>
|
||||
{item.data.Name}
|
||||
</Typography>
|
||||
)}
|
||||
<Stack
|
||||
direction="row"
|
||||
gap={2}
|
||||
justifyItems="flex-start"
|
||||
alignItems="center"
|
||||
>
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{item.data.ProductionYear ?? ""}
|
||||
{item.data.Status === "Continuing"
|
||||
? " - Present"
|
||||
: item.data.EndDate &&
|
||||
` - ${new Date(item.data.EndDate).getFullYear()}`}
|
||||
</Typography>
|
||||
|
||||
{seasons.data?.TotalRecordCount && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{seasons.data.TotalRecordCount > 1
|
||||
? `${seasons.data.TotalRecordCount} Seasons`
|
||||
: `${seasons.data.TotalRecordCount} Season`}
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
{item.data.OfficialRating && (
|
||||
<Chip
|
||||
variant="filled"
|
||||
size="small"
|
||||
label={item.data.OfficialRating}
|
||||
/>
|
||||
)}
|
||||
|
||||
{item.data.CommunityRating && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.25em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
// fontSize: "2.2em",
|
||||
color: yellow[400],
|
||||
}}
|
||||
>
|
||||
star
|
||||
</div>
|
||||
<Typography
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
>
|
||||
{Math.round(item.data.CommunityRating * 10) / 10}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
{item.data.CriticRating && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.25em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
color:
|
||||
item.data.CriticRating > 50 ? green[400] : red[400],
|
||||
}}
|
||||
>
|
||||
{item.data.CriticRating > 50 ? "thumb_up" : "thumb_down"}
|
||||
</div>
|
||||
<Typography
|
||||
style={{
|
||||
opacity: "0.8",
|
||||
}}
|
||||
variant="subtitle2"
|
||||
>
|
||||
{item.data.CriticRating}
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{Boolean(item.data.RunTimeTicks) && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{getRuntime(item.data.RunTimeTicks ?? 0)}
|
||||
</Typography>
|
||||
)}
|
||||
{Boolean(item.data.RunTimeTicks) && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{endsAt(
|
||||
(item.data.RunTimeTicks ?? 0) -
|
||||
(item.data.UserData?.PlaybackPositionTicks ?? 0),
|
||||
)}
|
||||
</Typography>
|
||||
)}
|
||||
<Typography variant="subtitle2" style={{ opacity: 0.8 }}>
|
||||
{item.data.Genres?.slice(0, 5).join(" / ")}
|
||||
</Typography>
|
||||
</Stack>
|
||||
</div>
|
||||
|
||||
<ItemHeader item={item.data} api={api} scrollTargetRef={containerRef}>
|
||||
<div className="item-hero-buttons-container">
|
||||
<div
|
||||
className="flex flex-row"
|
||||
@@ -563,7 +346,7 @@ function SeriesTitlePage() {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ItemHeader>
|
||||
<div className="item-detail">
|
||||
<div style={{ width: "100%" }}>
|
||||
{(item.data.Taglines?.length ?? 0) > 0 && (
|
||||
|
||||
@@ -15,15 +15,25 @@ export const AVAILABLE_VIEWS: Array<{
|
||||
compatibleCollectionTypes: [CollectionType.Movies],
|
||||
},
|
||||
{
|
||||
title: "Trailers",
|
||||
value: BaseItemKind.Trailer,
|
||||
compatibleCollectionTypes: [CollectionType.Movies],
|
||||
title: "Shows",
|
||||
value: BaseItemKind.Series,
|
||||
compatibleCollectionTypes: [CollectionType.Tvshows],
|
||||
},
|
||||
{
|
||||
title: "Albums",
|
||||
value: BaseItemKind.MusicAlbum,
|
||||
compatibleCollectionTypes: [CollectionType.Music],
|
||||
},
|
||||
{
|
||||
title: "Collections",
|
||||
value: BaseItemKind.CollectionFolder,
|
||||
compatibleCollectionTypes: [CollectionType.Movies, CollectionType.Boxsets],
|
||||
},
|
||||
{
|
||||
title: "Books",
|
||||
value: BaseItemKind.Book,
|
||||
compatibleCollectionTypes: [CollectionType.Books],
|
||||
},
|
||||
{
|
||||
title: "Genres",
|
||||
compatibleCollectionTypes: [
|
||||
@@ -34,20 +44,15 @@ export const AVAILABLE_VIEWS: Array<{
|
||||
value: BaseItemKind.Genre,
|
||||
},
|
||||
{
|
||||
title: "Shows",
|
||||
value: BaseItemKind.Series,
|
||||
compatibleCollectionTypes: [CollectionType.Tvshows],
|
||||
title: "Trailers",
|
||||
value: BaseItemKind.Trailer,
|
||||
compatibleCollectionTypes: [CollectionType.Movies],
|
||||
},
|
||||
{
|
||||
title: "TV Networks",
|
||||
value: BaseItemKind.Studio,
|
||||
compatibleCollectionTypes: [CollectionType.Tvshows],
|
||||
},
|
||||
{
|
||||
title: "Albums",
|
||||
value: BaseItemKind.MusicAlbum,
|
||||
compatibleCollectionTypes: [CollectionType.Music],
|
||||
},
|
||||
{
|
||||
title: "Album Artist",
|
||||
value: BaseItemKind.MusicArtist,
|
||||
@@ -68,11 +73,6 @@ export const AVAILABLE_VIEWS: Array<{
|
||||
value: BaseItemKind.Audio,
|
||||
compatibleCollectionTypes: [CollectionType.Music],
|
||||
},
|
||||
{
|
||||
title: "Books",
|
||||
value: BaseItemKind.Book,
|
||||
compatibleCollectionTypes: [CollectionType.Books],
|
||||
},
|
||||
];
|
||||
|
||||
export const SORT_BY_OPTIONS: Array<{
|
||||
|
||||
Reference in new issue
Block a user