From 64c5b7570bec55e6948a1b01b774cd8bc85d18a7 Mon Sep 17 00:00:00 2001 From: --remove-section Date: Fri, 19 Dec 2025 01:33:57 +0530 Subject: [PATCH] refactor: cleanup item pages code and make them more perfomant --- src/components/buttons/playButton.tsx | 9 +- src/components/itemHeader/index.tsx | 318 +++++++++++++++++- src/components/itemHeader/itemHeader.scss | 98 ++++++ src/routes/_api/artist/$id.tsx | 119 +------ src/routes/_api/boxset/$id.tsx | 232 +------------ src/routes/_api/episode/$id.tsx | 343 +------------------ src/routes/_api/item/$id.tsx | 391 ++-------------------- src/routes/_api/person/$id.tsx | 116 ++----- src/routes/_api/series/$id.tsx | 233 +------------ src/utils/constants/library.ts | 32 +- 10 files changed, 521 insertions(+), 1370 deletions(-) create mode 100644 src/components/itemHeader/itemHeader.scss diff --git a/src/components/buttons/playButton.tsx b/src/components/buttons/playButton.tsx index d5b8042..ef65fa9 100644 --- a/src/components/buttons/playButton.tsx +++ b/src/components/buttons/playButton.tsx @@ -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} > diff --git a/src/components/itemHeader/index.tsx b/src/components/itemHeader/index.tsx index 964e8b4..35b3ee0 100644 --- a/src/components/itemHeader/index.tsx +++ b/src/components/itemHeader/index.tsx @@ -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
Item Header
; +interface ItemHeaderProps { + item: BaseItemDto; + api: Api | undefined; + mediaQualityInfo?: MediaQualityInfo; + scrollTargetRef?: RefObject; + children?: ReactNode; +} + +const ItemHeader = ({ + item, + api, + mediaQualityInfo, + scrollTargetRef, + children, +}: ItemHeaderProps) => { + return ( +
+
+ {scrollTargetRef && ( + + )} +
+
+ {item.ImageTags?.Primary ? ( +
+ + {item.Name { + e.currentTarget.style.opacity = "1"; + }} + className="item-hero-image" + /> +
+ ) : ( +
+ {getTypeIcon(item.Type ?? "Movie")} +
+ )} +
+
+ {item.ImageTags?.Logo ? ( + {item.Name { + e.currentTarget.style.opacity = "1"; + }} + className="item-hero-logo" + /> + ) : ( + + {item.Name} + + )} + + {mediaQualityInfo?.isUHD && ( + ultra hd + )} + {mediaQualityInfo?.isHD && ( + hd + )} + {mediaQualityInfo?.isSD && ( + sd + )} + {mediaQualityInfo?.isSDR && ( + sdr + )} + {mediaQualityInfo?.isHDR && + !mediaQualityInfo?.isHDR10 && + !mediaQualityInfo?.isHDR10Plus && ( + hdr + )} + {mediaQualityInfo?.isHDR10 && ( + hdr10 + )} + {item.PremiereDate && ( + + {item.ProductionYear ?? ""} + + )} + {item.OfficialRating && ( + + )} + + {item.CommunityRating && ( +
+
+ star +
+ + {Math.round(item.CommunityRating * 10) / 10} + +
+ )} + {item.CriticRating && ( +
+
50 ? green[400] : red[400], + }} + > + {item.CriticRating > 50 ? "thumb_up" : "thumb_down"} +
+ + {item.CriticRating} + +
+ )} + + {item.RunTimeTicks && ( + + {getRuntime(item.RunTimeTicks)} + + )} + {item.RunTimeTicks && ( + + {endsAt( + item.RunTimeTicks - (item.UserData?.PlaybackPositionTicks ?? 0), + )} + + )} + + {item.Genres?.slice(0, 4).join(" / ")} + +
+ {mediaQualityInfo && ( + + {mediaQualityInfo?.isHDR10Plus && ( + hdr10+ + )} + {mediaQualityInfo.isDts && ( + dts + )} + {mediaQualityInfo.isDtsHDMA && ( + dts-hd ma + )} + {mediaQualityInfo.isAtmos && mediaQualityInfo.isDolbyVision && ( + dolby vision atmos + )} + {mediaQualityInfo.isAtmos && !mediaQualityInfo.isDolbyVision && ( + dolby atmos + )} + {mediaQualityInfo.isDolbyVision && !mediaQualityInfo.isAtmos && ( + dolby vision + )} + {mediaQualityInfo.isTrueHD && ( + dolby truehd + )} + {mediaQualityInfo.isDD && ( + dolby digital + )} + + )} +
+ {children} +
+ ); }; export default ItemHeader; diff --git a/src/components/itemHeader/itemHeader.scss b/src/components/itemHeader/itemHeader.scss new file mode 100644 index 0000000..308adca --- /dev/null +++ b/src/components/itemHeader/itemHeader.scss @@ -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; + } +} diff --git a/src/routes/_api/artist/$id.tsx b/src/routes/_api/artist/$id.tsx index df545a7..e8443ef 100644 --- a/src/routes/_api/artist/$id.tsx +++ b/src/routes/_api/artist/$id.tsx @@ -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(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" >
-
-
- { - e.currentTarget.style.opacity = "1"; - }} - style={{ - y: parallax, - }} - /> -
-
- {item.data.ImageTags?.Primary ? ( -
- - {item.data.Name { - e.currentTarget.style.opacity = "1"; - }} - className="item-hero-image" - /> -
- ) : ( -
- {getTypeIcon(item.data.Type ?? "MusicArtist")} -
- )} -
-
- {item.data.ImageTags?.Logo ? ( - {item.data.Name { - e.currentTarget.style.opacity = "1"; - }} - className="item-hero-logo" - /> - ) : ( - - {item.data.Name} - - )} - + +
-
+
{ - 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(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" >
-
-
- {item.data.BackdropImageTags?.length ? ( - { - e.currentTarget.style.opacity = "1"; - }} - style={{ - y: parallax, - }} - /> - ) : ( - { - e.currentTarget.style.opacity = "1"; - }} - style={{ - y: parallax, - }} - /> - )} -
-
- {item.data.ImageTags?.Primary && - item.data.ImageBlurHashes?.Primary ? ( -
- - {item.data.Name { - e.currentTarget.style.opacity = "1"; - }} - className="item-hero-image" - /> -
- ) : ( -
- {getTypeIcon(item.data.Type ?? "BoxSet")} -
- )} -
-
- {item.data.ImageTags?.Logo ? ( - {item.data.Name { - e.currentTarget.style.opacity = "1"; - }} - className="item-hero-logo" - /> - ) : ( - - {item.data.Name} - - )} - - - {item.data.PremiereDate && ( - - {item.data.ProductionYear ?? ""} - - )} - {item.data.OfficialRating && ( - - )} - - {item.data.CommunityRating && ( -
-
- star -
- - {Math.round(item.data.CommunityRating * 10) / 10} - -
- )} - {item.data.CriticRating && ( -
-
50 ? green[400] : red[400], - }} - > - {item.data.CriticRating > 50 ? "thumb_up" : "thumb_down"} -
- - {item.data.CriticRating} - -
- )} - - {item.data.RunTimeTicks && ( - - {getRuntime(item.data.RunTimeTicks)} - - )} - {item.data.RunTimeTicks && ( - - {endsAt( - item.data.RunTimeTicks - - (item.data.UserData?.PlaybackPositionTicks ?? 0), - )} - - )} - - {item.data.Genres?.slice(0, 4).join(" / ")} - -
-
+
-
+
-
-
- {item.data.ParentBackdropImageTags?.length ? ( - - ) : ( - - )} -
-
- {item.data.ImageTags?.Primary ? ( -
- - {item.data.Name { - e.currentTarget.style.opacity = "1"; - }} - className="item-hero-image" - /> -
- ) : ( -
- {getTypeIcon(item.data.Type ?? "Episode")} -
- )} -
-
- - - {item.data.ParentLogoItemId ? ( - {item.data.SeriesName { - e.currentTarget.style.opacity = "1"; - }} - className="item-hero-logo" - /> - ) : ( - item.data.SeriesName - )} - - - - S{item.data.ParentIndexNumber ?? 0}:E - {item.data.IndexNumberEnd - ? `${item.data.IndexNumber ?? 0} / ${ - item.data.IndexNumberEnd ?? 0 - }` - : `${item.data.IndexNumber ?? 0}`}{" "} - {item.data.Name} - - - - {mediaQualityInfo?.isUHD && ( - ultra hd - )} - {mediaQualityInfo?.isHD && ( - hd - )} - {mediaQualityInfo?.isSD && ( - sd - )} - {mediaQualityInfo?.isSDR && ( - sdr - )} - {mediaQualityInfo?.isHDR && - !mediaQualityInfo?.isHDR10 && - !mediaQualityInfo?.isHDR10Plus && ( - hdr - )} - {mediaQualityInfo?.isHDR10 && ( - hdr10 - )} - {item.data.PremiereDate && ( - - {item.data.ProductionYear ?? ""} - - )} - {item.data.OfficialRating && ( - - )} - - {item.data.CommunityRating && ( -
-
- star -
- - {Math.round(item.data.CommunityRating * 10) / 10} - -
- )} - {item.data.CriticRating && ( -
-
50 ? green[400] : red[400], - }} - > - {item.data.CriticRating > 50 ? "thumb_up" : "thumb_down"} -
- - {item.data.CriticRating} - -
- )} - - {item.data.RunTimeTicks && ( - - {getRuntime(item.data.RunTimeTicks)} - - )} - {item.data.RunTimeTicks && ( - - {endsAt( - item.data.RunTimeTicks - - (item.data.UserData?.PlaybackPositionTicks ?? 0), - )} - - )} - - {item.data.Genres?.slice(0, 4).join(" / ")} - -
- {mediaQualityInfo && ( - - {mediaQualityInfo?.isHDR10Plus && ( - hdr10+ - )} - {mediaQualityInfo.isDts && ( - dts - )} - {mediaQualityInfo.isDtsHDMA && ( - dts-hd ma - )} - {mediaQualityInfo.isAtmos && mediaQualityInfo.isDolbyVision && ( - dolby vision atmos - )} - {mediaQualityInfo.isAtmos && - !mediaQualityInfo.isDolbyVision && ( - dolby atmos - )} - {mediaQualityInfo.isDolbyVision && - !mediaQualityInfo.isAtmos && ( - dolby vision - )} - {mediaQualityInfo.isTrueHD && ( - dolby truehd - )} - {mediaQualityInfo.isDD && ( - dolby digital - )} - {mediaQualityInfo.isDDP && ( - dolby digital plus - )} - {mediaQualityInfo.isIMAX && ( - imax - )} - - )} -
+
-
+
{ 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} > -
-
- -
-
- {item.data.ImageTags?.Primary ? ( -
- - {item.data.Name { - e.currentTarget.style.opacity = "1"; - }} - className="item-hero-image" - /> -
- ) : ( -
- {getTypeIcon(item.data.Type ?? "Movie")} -
- )} -
-
- {item.data.ImageTags?.Logo ? ( - {item.data.Name { - e.currentTarget.style.opacity = "1"; - }} - className="item-hero-logo" - /> - ) : ( - - {item.data.Name} - - )} - - {mediaQualityInfo?.isUHD && ( - ultra hd - )} - {mediaQualityInfo?.isHD && ( - hd - )} - {mediaQualityInfo?.isSD && ( - sd - )} - {mediaQualityInfo?.isSDR && ( - sdr - )} - {mediaQualityInfo?.isHDR && - !mediaQualityInfo?.isHDR10 && - !mediaQualityInfo?.isHDR10Plus && ( - hdr - )} - {mediaQualityInfo?.isHDR10 && ( - hdr10 - )} - {item.data.PremiereDate && ( - - {item.data.ProductionYear ?? ""} - - )} - {item.data.OfficialRating && ( - - )} - - {item.data.CommunityRating && ( -
-
- star -
- - {Math.round(item.data.CommunityRating * 10) / 10} - -
- )} - {item.data.CriticRating && ( -
-
50 ? green[400] : red[400], - }} - > - {item.data.CriticRating > 50 ? "thumb_up" : "thumb_down"} -
- - {item.data.CriticRating} - -
- )} - - {item.data.RunTimeTicks && ( - - {getRuntime(item.data.RunTimeTicks)} - - )} - {item.data.RunTimeTicks && ( - - {endsAt( - item.data.RunTimeTicks - - (item.data.UserData?.PlaybackPositionTicks ?? 0), - )} - - )} - - {item.data.Genres?.slice(0, 4).join(" / ")} - -
- {mediaQualityInfo && ( - - {mediaQualityInfo?.isHDR10Plus && ( - hdr10+ - )} - {mediaQualityInfo.isDts && ( - dts - )} - {mediaQualityInfo.isDtsHDMA && ( - dts-hd ma - )} - {mediaQualityInfo.isAtmos && mediaQualityInfo.isDolbyVision && ( - dolby vision atmos - )} - {mediaQualityInfo.isAtmos && - !mediaQualityInfo.isDolbyVision && ( - dolby atmos - )} - {mediaQualityInfo.isDolbyVision && - !mediaQualityInfo.isAtmos && ( - dolby vision - )} - {mediaQualityInfo.isTrueHD && ( - dolby truehd - )} - {mediaQualityInfo.isDD && ( - dolby digital - )} - {mediaQualityInfo.isDDP && ( - dolby digital plus - )} - {mediaQualityInfo.isIMAX && ( - imax - )} - - )} -
+
-
+
{(item.data.Taglines?.length ?? 0) > 0 && ( diff --git a/src/routes/_api/person/$id.tsx b/src/routes/_api/person/$id.tsx index 803311f..6783746 100644 --- a/src/routes/_api/person/$id.tsx +++ b/src/routes/_api/person/$id.tsx @@ -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} > -
-
- {item.data.Name { - e.currentTarget.style.opacity = "1"; - }} - /> + +
+
+
+ +
-
- {item.data.ImageTags?.Primary && ( -
- - {item.data.Name { - e.currentTarget.style.opacity = "1"; - }} - className="item-hero-image" - /> -
- )} -
-
- - {item.data.Name} - - - -
-
+
{ 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( @@ -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} > -
-
- - {item.data.BackdropImageTags ? ( - { - console.info("Image Loaded"); - setBackdropImageLoaded(true); - }} - motionProps={{ - initial: { opacity: 0 }, - animate: { opacity: backdropImageLoaded ? 1 : 0 }, - exit: { opacity: 0 }, - transition: { duration: 0.2 }, - }} - /> - ) : ( - - )} - -
-
- {item.data.ImageTags?.Primary ? ( -
- - {item.data.Name { - e.currentTarget.style.opacity = "1"; - }} - className="item-hero-image" - /> -
- ) : ( -
- {getTypeIcon(item.data.Type ?? "Series")} -
- )} -
-
- {item.data.ImageTags?.Logo ? ( - {item.data.Name { - e.currentTarget.style.opacity = "1"; - }} - className="item-hero-logo" - /> - ) : ( - - {item.data.Name} - - )} - - - {item.data.ProductionYear ?? ""} - {item.data.Status === "Continuing" - ? " - Present" - : item.data.EndDate && - ` - ${new Date(item.data.EndDate).getFullYear()}`} - - - {seasons.data?.TotalRecordCount && ( - - {seasons.data.TotalRecordCount > 1 - ? `${seasons.data.TotalRecordCount} Seasons` - : `${seasons.data.TotalRecordCount} Season`} - - )} - - {item.data.OfficialRating && ( - - )} - - {item.data.CommunityRating && ( -
-
- star -
- - {Math.round(item.data.CommunityRating * 10) / 10} - -
- )} - {item.data.CriticRating && ( -
-
50 ? green[400] : red[400], - }} - > - {item.data.CriticRating > 50 ? "thumb_up" : "thumb_down"} -
- - {item.data.CriticRating} - -
- )} - - {Boolean(item.data.RunTimeTicks) && ( - - {getRuntime(item.data.RunTimeTicks ?? 0)} - - )} - {Boolean(item.data.RunTimeTicks) && ( - - {endsAt( - (item.data.RunTimeTicks ?? 0) - - (item.data.UserData?.PlaybackPositionTicks ?? 0), - )} - - )} - - {item.data.Genres?.slice(0, 5).join(" / ")} - -
-
- +
-
+
{(item.data.Taglines?.length ?? 0) > 0 && ( diff --git a/src/utils/constants/library.ts b/src/utils/constants/library.ts index 5999b6d..0ef7d3a 100644 --- a/src/utils/constants/library.ts +++ b/src/utils/constants/library.ts @@ -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<{