fix: item pages not renderinf
This commit is contained in:
7 files changed
+330
-281
No files matched your search
@@ -0,0 +1,120 @@
|
||||
import {
|
||||
type HTMLMotionProps,
|
||||
motion,
|
||||
useScroll,
|
||||
useTransform,
|
||||
} from "motion/react";
|
||||
import React, { type RefObject, useEffect, useState } from "react";
|
||||
|
||||
interface ItemBackdropProps {
|
||||
targetRef: RefObject<HTMLElement | null>;
|
||||
backdropSrc?: string;
|
||||
fallbackSrc: string;
|
||||
alt: string;
|
||||
distance?: number; // parallax distance
|
||||
className?: string;
|
||||
onLoad?: (e: React.SyntheticEvent<HTMLImageElement>) => void;
|
||||
motionProps?: HTMLMotionProps<"img">;
|
||||
}
|
||||
|
||||
/**
|
||||
* ItemBackdrop delays applying motion-driven parallax until after mount
|
||||
* to avoid hydration timing errors ("Target ref is defined but not hydrated").
|
||||
* It accepts a scroll container ref from the parent; if the ref is not yet
|
||||
* attached, it renders a static img to prevent motion from touching an
|
||||
* unhydrated DOM node.
|
||||
*/
|
||||
function ItemBackdropContent({
|
||||
targetRef,
|
||||
src,
|
||||
alt,
|
||||
distance,
|
||||
className,
|
||||
onLoad,
|
||||
motionProps,
|
||||
}: {
|
||||
targetRef: RefObject<HTMLElement | null>;
|
||||
src: string;
|
||||
alt: string;
|
||||
distance: number;
|
||||
className?: string;
|
||||
onLoad?: (e: React.SyntheticEvent<HTMLImageElement>) => void;
|
||||
motionProps?: HTMLMotionProps<"img">;
|
||||
}) {
|
||||
const { scrollYProgress } = useScroll({
|
||||
target: targetRef,
|
||||
offset: ["start start", "60vh start"],
|
||||
});
|
||||
const y = useTransform(scrollYProgress, [0, 1], [-distance, distance]);
|
||||
return (
|
||||
<motion.img
|
||||
alt={alt}
|
||||
src={src}
|
||||
className={className ?? "item-hero-backdrop"}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
onLoad?.(e);
|
||||
}}
|
||||
style={{ y }}
|
||||
{...motionProps}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function ItemBackdrop({
|
||||
targetRef,
|
||||
backdropSrc,
|
||||
fallbackSrc,
|
||||
alt,
|
||||
distance = 50,
|
||||
className,
|
||||
onLoad,
|
||||
motionProps,
|
||||
}: ItemBackdropProps) {
|
||||
const src = backdropSrc || fallbackSrc;
|
||||
const [ready, setReady] = useState(false);
|
||||
// Poll a few animation frames until the target ref hydrates to avoid premature motion initialization.
|
||||
useEffect(() => {
|
||||
if (ready) return;
|
||||
let frame = 0;
|
||||
let raf: number;
|
||||
const tick = () => {
|
||||
if (targetRef.current || frame > 5) {
|
||||
setReady(true);
|
||||
return;
|
||||
}
|
||||
frame++;
|
||||
raf = requestAnimationFrame(tick);
|
||||
};
|
||||
tick();
|
||||
return () => cancelAnimationFrame(raf);
|
||||
}, [targetRef, ready]);
|
||||
|
||||
if (!ready) {
|
||||
return (
|
||||
<img
|
||||
alt={alt}
|
||||
src={src}
|
||||
className={className ?? "item-hero-backdrop"}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
onLoad?.(e);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ItemBackdropContent
|
||||
targetRef={targetRef}
|
||||
src={src}
|
||||
alt={alt}
|
||||
distance={distance}
|
||||
className={className}
|
||||
onLoad={onLoad}
|
||||
motionProps={motionProps}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default ItemBackdrop;
|
||||
@@ -1,39 +1,31 @@
|
||||
import React, { useLayoutEffect, useMemo } from "react";
|
||||
|
||||
import Box from "@mui/material/Box";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import { BaseItemKind, SortOrder } from "@jellyfin/sdk/lib/generated-client";
|
||||
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 CircularProgress from "@mui/material/CircularProgress";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { getRuntimeCompact } from "@/utils/date/time";
|
||||
|
||||
import { Card } from "@/components/card/card";
|
||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||
|
||||
import React, { useLayoutEffect, useMemo } from "react";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import PlayButton from "@/components/buttons/playButton";
|
||||
import { Card } from "@/components/card/card";
|
||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import { getRuntimeCompact } from "@/utils/date/time";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import "./album.scss";
|
||||
|
||||
import { Chip } from "@mui/material";
|
||||
import { createFileRoute, Link } from "@tanstack/react-router";
|
||||
import { createPortal } from "react-dom";
|
||||
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import TagChip from "@/components/tagChip";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { Chip } from "@mui/material";
|
||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||
import { createPortal } from "react-dom";
|
||||
|
||||
export const Route = createFileRoute("/_api/album/$id")({
|
||||
component: MusicAlbumTitlePage,
|
||||
@@ -95,7 +87,8 @@ function MusicAlbumTitlePage() {
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
||||
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
|
||||
const lastBackdropRef = React.useRef<string | undefined>(undefined);
|
||||
|
||||
const allDiscs = useMemo(() => {
|
||||
const discs: number[] = [];
|
||||
@@ -111,15 +104,22 @@ function MusicAlbumTitlePage() {
|
||||
}
|
||||
return discs;
|
||||
}, [musicTracks.data]);
|
||||
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (item.isSuccess) {
|
||||
setAppBackdrop(
|
||||
`${api?.basePath}/Items/${item.data?.ParentBackdropItemId}/Images/Backdrop`,
|
||||
item.data?.Id,
|
||||
);
|
||||
if (item.isSuccess && item.data) {
|
||||
const backdropItemId = item.data.ParentBackdropItemId;
|
||||
if (backdropItemId && lastBackdropRef.current !== backdropItemId) {
|
||||
const hash =
|
||||
item.data.ImageBlurHashes?.Backdrop?.[
|
||||
item.data.ParentBackdropImageTags?.[0] ?? ""
|
||||
];
|
||||
if (hash) {
|
||||
setBackdrop(hash);
|
||||
lastBackdropRef.current = backdropItemId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [item.isSuccess]);
|
||||
}, [item.isSuccess, item.data, setBackdrop]);
|
||||
|
||||
if (item.isPending || similarItems.isPending) {
|
||||
return (
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
import React, {
|
||||
useState,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
|
||||
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 useParallax from "@/utils/hooks/useParallax";
|
||||
import { AnimatePresence, motion, useScroll } from "motion/react";
|
||||
|
||||
import {
|
||||
BaseItemKind,
|
||||
ItemFields,
|
||||
@@ -23,25 +5,38 @@ import {
|
||||
} 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 { useQuery } from "@tanstack/react-query";
|
||||
import { AnimatePresence, motion, useScroll } from "motion/react";
|
||||
import React, {
|
||||
type ReactNode,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import { Blurhash } from "react-blurhash";
|
||||
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import { Card } from "@/components/card/card";
|
||||
import { Blurhash } from "react-blurhash";
|
||||
|
||||
import { ArtistAlbum } from "@/components/layouts/artist/artistAlbum";
|
||||
import MusicTrack from "@/components/musicTrack";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import useParallax from "@/utils/hooks/useParallax";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
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";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
|
||||
type TabPanelProp = {
|
||||
@@ -182,16 +177,13 @@ function ArtistTitlePage() {
|
||||
const { setBackdrop } = useBackdropStore();
|
||||
useEffect(() => {
|
||||
if (item.isSuccess && item.data) {
|
||||
setBackdrop(
|
||||
`${api?.basePath}/Items/${item.data.Id}/Images/Backdrop`,
|
||||
item.data.Id,
|
||||
);
|
||||
setBackdrop(`${api?.basePath}/Items/${item.data.Id}/Images/Backdrop`);
|
||||
}
|
||||
}, [item.isSuccess]);
|
||||
|
||||
const pageRef = useRef(null);
|
||||
const scrollTargetRef = useRef<HTMLDivElement | null>(null);
|
||||
const { scrollYProgress } = useScroll({
|
||||
target: pageRef,
|
||||
target: scrollTargetRef,
|
||||
offset: ["start start", "60vh start"],
|
||||
});
|
||||
const parallax = useParallax(scrollYProgress, 50);
|
||||
@@ -226,8 +218,8 @@ function ArtistTitlePage() {
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
className="scrollY item item-artist"
|
||||
ref={pageRef}
|
||||
>
|
||||
<div ref={scrollTargetRef} />
|
||||
<div className="item-hero flex flex-row">
|
||||
<div className="item-hero-backdrop-container">
|
||||
<motion.img
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
import React, { useLayoutEffect, useRef } from "react";
|
||||
|
||||
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 useParallax from "@/utils/hooks/useParallax";
|
||||
import { motion, useScroll } from "motion/react";
|
||||
|
||||
import {
|
||||
BaseItemKind,
|
||||
ItemFields,
|
||||
@@ -17,30 +6,34 @@ import {
|
||||
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 { Card } from "@/components/card/card";
|
||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import { motion, useScroll } 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 heroBg from "@/assets/herobg.png";
|
||||
import { Card } from "@/components/card/card";
|
||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||
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";
|
||||
import { green, red, yellow } from "@mui/material/colors";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/_api/boxset/$id")({
|
||||
component: BoxSetTitlePage,
|
||||
@@ -113,19 +106,17 @@ function BoxSetTitlePage() {
|
||||
tag: item.data.BackdropImageTags[0],
|
||||
},
|
||||
),
|
||||
item.data.Id,
|
||||
);
|
||||
} else {
|
||||
setBackdrop("", "");
|
||||
setBackdrop("");
|
||||
}
|
||||
}
|
||||
}, [item.isSuccess]);
|
||||
|
||||
const pageRef = useRef(null);
|
||||
const scrollTargetRef = useRef<HTMLDivElement | null>(null);
|
||||
const { scrollYProgress } = useScroll({
|
||||
target: pageRef,
|
||||
target: scrollTargetRef,
|
||||
offset: ["start start", "60vh start"],
|
||||
layoutEffect: false,
|
||||
});
|
||||
const parallax = useParallax(scrollYProgress, 50);
|
||||
|
||||
@@ -159,8 +150,8 @@ function BoxSetTitlePage() {
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
className="scrollY item item-boxset padded-top"
|
||||
ref={pageRef}
|
||||
>
|
||||
<div ref={scrollTargetRef} />
|
||||
<div className="item-hero flex flex-row">
|
||||
<div className="item-hero-backdrop-container">
|
||||
{item.data.BackdropImageTags?.length ? (
|
||||
|
||||
@@ -1,33 +1,27 @@
|
||||
import React, { useState, useRef, useMemo, useEffect } from "react";
|
||||
|
||||
import Box from "@mui/material/Box";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
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 { green, red, yellow } from "@mui/material/colors";
|
||||
|
||||
import { Blurhash } from "react-blurhash";
|
||||
|
||||
import useParallax from "@/utils/hooks/useParallax";
|
||||
import { motion, useScroll } from "motion/react";
|
||||
|
||||
import {
|
||||
BaseItemKind,
|
||||
MediaStreamType,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
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 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 { motion } from "motion/react";
|
||||
import React, { useEffect, useMemo, useRef, useState } 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 TrailerButton from "@/components/buttons/trailerButton";
|
||||
// import useParallax from "@/utils/hooks/useParallax";
|
||||
import ItemBackdrop from "@/components/itemBackdrop";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
@@ -35,32 +29,30 @@ import { endsAt, getRuntime } from "@/utils/date/time";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import "./episode.scss";
|
||||
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { createFileRoute, Link } from "@tanstack/react-router";
|
||||
import ultraHdIcon from "@/assets/icons/4k.svg";
|
||||
import dolbyAtmosIcon from "@/assets/icons/dolby-atmos.svg";
|
||||
import dolbyDigitalPlusIcon from "@/assets/icons/dolby-digital-plus.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 dolbyVisionAtmosIcon from "@/assets/icons/dolby-vision-atmos.png";
|
||||
import dolbyVisionIcon from "@/assets/icons/dolby-vision.svg";
|
||||
import dtsHdMaIcon from "@/assets/icons/dts-hd-ma.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 hdr10PlusIcon from "@/assets/icons/hdr10-plus.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 type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||
|
||||
import { Card } from "@/components/card/card";
|
||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||
import IconLink from "@/components/iconLink";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||
import type MediaQualityInfo from "@/utils/types/mediaQualityInfo";
|
||||
|
||||
export const Route = createFileRoute("/_api/episode/$id")({
|
||||
component: EpisodeTitlePage,
|
||||
@@ -103,7 +95,7 @@ function EpisodeTitlePage() {
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
||||
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
|
||||
|
||||
const [selectedVideoTrack, setSelectedVideoTrack] = useState(0);
|
||||
const [selectedAudioTrack, setSelectedAudioTrack] = useState(0);
|
||||
@@ -157,7 +149,6 @@ function EpisodeTitlePage() {
|
||||
return item.data?.People?.filter((itm) => itm.Type === "Producer") ?? [];
|
||||
}, [item.data?.Id]);
|
||||
|
||||
|
||||
const mediaQualityInfo = useMemo<MediaQualityInfo>(() => {
|
||||
const checkAtmos = audioTracks.filter((audio) =>
|
||||
audio.DisplayTitle?.toLocaleLowerCase().includes("atmos"),
|
||||
@@ -254,22 +245,20 @@ function EpisodeTitlePage() {
|
||||
};
|
||||
}, [item.data?.Id]);
|
||||
|
||||
const lastBackdropRef = useRef<string | undefined>(undefined);
|
||||
useEffect(() => {
|
||||
if (api && item.isSuccess && item.data) {
|
||||
setAppBackdrop(
|
||||
`${api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop`,
|
||||
item.data.Id,
|
||||
);
|
||||
}
|
||||
}, [item.isSuccess]);
|
||||
if (!api || !item.isSuccess || !item.data) return;
|
||||
const tag = item.data.ParentBackdropImageTags?.[0];
|
||||
// Prefer blurhash if available; fallback to URL
|
||||
const hash = item.data.ImageBlurHashes?.Backdrop?.[tag ?? ""];
|
||||
|
||||
const pageRef = useRef(null);
|
||||
const { scrollYProgress } = useScroll({
|
||||
target: pageRef,
|
||||
offset: ["start start", "60vh start"],
|
||||
layoutEffect: false,
|
||||
});
|
||||
const parallax = useParallax(scrollYProgress, 50);
|
||||
if (hash && lastBackdropRef.current !== hash) {
|
||||
lastBackdropRef.current = hash;
|
||||
setBackdrop(hash);
|
||||
}
|
||||
}, [api, item.isSuccess, item.data, setBackdrop]);
|
||||
|
||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
if (item.isPending) {
|
||||
return (
|
||||
@@ -301,42 +290,31 @@ function EpisodeTitlePage() {
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
className="scrollY padded-top flex flex-column item item-episode"
|
||||
ref={pageRef}
|
||||
ref={containerRef}
|
||||
>
|
||||
<div className="item-hero">
|
||||
<div className="item-hero-backdrop-container">
|
||||
{item.data.ParentBackdropImageTags?.length ? (
|
||||
<motion.img
|
||||
<ItemBackdrop
|
||||
targetRef={containerRef}
|
||||
alt={item.data.Name ?? ""}
|
||||
src={
|
||||
backdropSrc={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data.ParentBackdropItemId ?? "",
|
||||
"Backdrop",
|
||||
{
|
||||
tag: item.data.ParentBackdropImageTags[0],
|
||||
},
|
||||
{ tag: item.data.ParentBackdropImageTags[0] },
|
||||
)
|
||||
}
|
||||
fallbackSrc={heroBg}
|
||||
className="item-hero-backdrop"
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
style={{
|
||||
y: parallax,
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<motion.img
|
||||
<ItemBackdrop
|
||||
targetRef={containerRef}
|
||||
alt={item.data.Name ?? ""}
|
||||
src={heroBg}
|
||||
fallbackSrc={heroBg}
|
||||
className="item-hero-backdrop"
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
style={{
|
||||
y: parallax,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -10,13 +10,14 @@ 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, useScroll } from "motion/react";
|
||||
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 useParallax from "@/utils/hooks/useParallax";
|
||||
import ItemBackdrop from "@/components/itemBackdrop";
|
||||
|
||||
import "./item.scss";
|
||||
|
||||
@@ -43,7 +44,6 @@ import MarkPlayedButton from "@/components/buttons/markPlayedButton";
|
||||
import PlayButton from "@/components/buttons/playButton";
|
||||
import TrailerButton from "@/components/buttons/trailerButton";
|
||||
import IconLink from "@/components/iconLink";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import ItemSkeleton from "@/components/skeleton/item";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
@@ -292,13 +292,8 @@ function ItemDetail() {
|
||||
}
|
||||
}, [item.data.Id]);
|
||||
|
||||
const pageRef = useRef(null);
|
||||
const { scrollYProgress } = useScroll({
|
||||
layoutEffect: false,
|
||||
target: pageRef,
|
||||
offset: ["start start", "60vh start"],
|
||||
});
|
||||
const parallax = useParallax(scrollYProgress, 50);
|
||||
// Provide a scroll target ref to the backdrop component.
|
||||
const scrollTargetRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
@@ -314,44 +309,25 @@ function ItemDetail() {
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
className="scrollY padded-top flex flex-column item item-default"
|
||||
ref={pageRef}
|
||||
ref={scrollTargetRef}
|
||||
>
|
||||
<div className="item-hero">
|
||||
<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,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<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"
|
||||
|
||||
@@ -1,57 +1,48 @@
|
||||
import React, { useState, useEffect, useRef, useMemo } from "react";
|
||||
|
||||
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import Box from "@mui/material/Box";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import { 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 { green, red, yellow } from "@mui/material/colors";
|
||||
|
||||
import useParallax from "@/utils/hooks/useParallax";
|
||||
import useDefaultSeason from "@/utils/hooks/useDefaultSeason";
|
||||
import { AnimatePresence, motion, useScroll } from "motion/react";
|
||||
|
||||
import { Blurhash } from "react-blurhash";
|
||||
|
||||
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { AnimatePresence, 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 { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import {
|
||||
endsAt,
|
||||
getRuntime,
|
||||
getRuntimeCompact,
|
||||
getRuntimeMusic,
|
||||
} from "@/utils/date/time";
|
||||
|
||||
import { Card } from "@/components/card/card";
|
||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
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";
|
||||
import TrailerButton from "@/components/buttons/trailerButton";
|
||||
import IconLink from "@/components/iconLink";
|
||||
import ShowMoreText from "@/components/showMoreText";
|
||||
import EpisodeSkeleton from "@/components/skeleton/episode";
|
||||
import { SeasonSelectorSkeleton } from "@/components/skeleton/seasonSelector";
|
||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
import IconLink from "@/components/iconLink";
|
||||
import EpisodeSkeleton from "@/components/skeleton/episode";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import { Link } from "@tanstack/react-router";
|
||||
|
||||
const getEpisodeDateString = (date: Date) => {
|
||||
const formatter = new Intl.DateTimeFormat(navigator.language ?? "en-US", {
|
||||
@@ -117,14 +108,19 @@ function SeriesTitlePage() {
|
||||
enabled: item.isSuccess,
|
||||
});
|
||||
|
||||
const [backdropImage, setBackdropImage] = useState<SeriesBackdropImage>(() => {
|
||||
const url = sessionStorage.getItem(`backdrop-${item.data?.Id}`);
|
||||
const key = sessionStorage.getItem(`backdrop-${item.data?.Id}-key`);
|
||||
return { url, key };
|
||||
});
|
||||
const [backdropImage, setBackdropImage] = useState<SeriesBackdropImage>(
|
||||
() => {
|
||||
const url = sessionStorage.getItem(`backdrop-${item.data?.Id}`);
|
||||
const key = sessionStorage.getItem(`backdrop-${item.data?.Id}-key`);
|
||||
return { url, key };
|
||||
},
|
||||
);
|
||||
const [backdropImageLoaded, setBackdropImageLoaded] = useState(false);
|
||||
|
||||
const [currentSeason, setCurrentSeason] = useDefaultSeason(seasons, item.data?.Id);
|
||||
const [currentSeason, setCurrentSeason] = useDefaultSeason(
|
||||
seasons,
|
||||
item.data?.Id,
|
||||
);
|
||||
|
||||
const currentSeasonNumber = Number(currentSeason);
|
||||
|
||||
@@ -187,6 +183,8 @@ function SeriesTitlePage() {
|
||||
return item.data?.People?.filter((itm) => itm.Type === "Producer") ?? [];
|
||||
}, [item.data?.Id]);
|
||||
|
||||
const lastBackdropHashRef = useRef<string | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
if (api && currentSeasonItem.isSuccess && item.isSuccess) {
|
||||
if (
|
||||
@@ -217,16 +215,17 @@ function SeriesTitlePage() {
|
||||
),
|
||||
key: currentSeasonItem.data?.BackdropImageTags?.[0],
|
||||
});
|
||||
setBackdrop(
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
currentSeasonItem.data?.Id ?? "",
|
||||
"Backdrop",
|
||||
{
|
||||
tag: currentSeasonItem.data?.BackdropImageTags?.[0],
|
||||
},
|
||||
),
|
||||
currentSeasonItem.data?.BackdropImageTags?.[0],
|
||||
);
|
||||
const seasonBackdropTag =
|
||||
currentSeasonItem.data?.BackdropImageTags?.[0];
|
||||
const seasonBackdropHash =
|
||||
currentSeasonItem.data?.ImageBlurHashes?.Backdrop?.[
|
||||
seasonBackdropTag ?? ""
|
||||
] ?? "";
|
||||
|
||||
if (lastBackdropHashRef.current !== seasonBackdropHash) {
|
||||
setBackdrop(seasonBackdropHash);
|
||||
lastBackdropHashRef.current = seasonBackdropHash;
|
||||
}
|
||||
setBackdropImageLoaded(false);
|
||||
} else if (
|
||||
item.isSuccess &&
|
||||
@@ -259,26 +258,28 @@ function SeriesTitlePage() {
|
||||
),
|
||||
key: item.data?.BackdropImageTags?.[0],
|
||||
});
|
||||
setBackdrop(
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
item.data?.Id ?? "",
|
||||
"Backdrop",
|
||||
{
|
||||
tag: item.data?.BackdropImageTags?.[0],
|
||||
},
|
||||
),
|
||||
item.data?.BackdropImageTags?.[0],
|
||||
);
|
||||
const seriesBackdropTag = item.data?.BackdropImageTags?.[0];
|
||||
const seriesBackdropHash =
|
||||
item.data?.ImageBlurHashes?.Backdrop?.[seriesBackdropTag ?? ""] ?? "";
|
||||
|
||||
if (lastBackdropHashRef.current !== seriesBackdropHash) {
|
||||
setBackdrop(seriesBackdropHash);
|
||||
lastBackdropHashRef.current = seriesBackdropHash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [currentSeasonItem.dataUpdatedAt]);
|
||||
}, [
|
||||
api,
|
||||
currentSeasonItem.data,
|
||||
currentSeasonItem.isSuccess,
|
||||
item.data,
|
||||
item.isSuccess,
|
||||
setBackdrop,
|
||||
backdropImage.key,
|
||||
]);
|
||||
|
||||
const pageRef = useRef(null);
|
||||
const { scrollYProgress } = useScroll({
|
||||
target: pageRef,
|
||||
offset: ["start start", "60vh start"],
|
||||
});
|
||||
const parallax = useParallax(scrollYProgress, 50);
|
||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||
// Parallax handled within ItemBackdrop to avoid hydration issues.
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
@@ -313,48 +314,36 @@ function SeriesTitlePage() {
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
className="scrollY padded-top flex flex-column item item-series"
|
||||
ref={pageRef}
|
||||
ref={containerRef}
|
||||
>
|
||||
<div className="item-hero">
|
||||
<div className="item-hero-backdrop-container">
|
||||
<AnimatePresence mode="wait">
|
||||
{item.data.BackdropImageTags ? (
|
||||
<motion.img
|
||||
<ItemBackdrop
|
||||
key={backdropImage.key}
|
||||
targetRef={containerRef}
|
||||
alt={item.data.Name ?? ""}
|
||||
src={backdropImage.url ?? ""}
|
||||
backdropSrc={backdropImage.url ?? ""}
|
||||
fallbackSrc={heroBg}
|
||||
className="item-hero-backdrop"
|
||||
initial={{
|
||||
opacity: 0,
|
||||
}}
|
||||
onLoad={() => {
|
||||
console.info("Image Loaded");
|
||||
setBackdropImageLoaded(true);
|
||||
}}
|
||||
animate={{
|
||||
opacity: backdropImageLoaded ? 1 : 0,
|
||||
}}
|
||||
exit={{
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.2,
|
||||
}}
|
||||
style={{
|
||||
y: parallax,
|
||||
motionProps={{
|
||||
initial: { opacity: 0 },
|
||||
animate: { opacity: backdropImageLoaded ? 1 : 0 },
|
||||
exit: { opacity: 0 },
|
||||
transition: { duration: 0.2 },
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<motion.img
|
||||
<ItemBackdrop
|
||||
targetRef={containerRef}
|
||||
alt={item.data.Name ?? ""}
|
||||
src={heroBg}
|
||||
fallbackSrc={heroBg}
|
||||
className="item-hero-backdrop"
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
style={{
|
||||
y: parallax,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
@@ -899,7 +888,10 @@ function SeriesTitlePage() {
|
||||
value={currentSeasonNumber}
|
||||
onChange={(e) => {
|
||||
const seasonIndex = Number(e.target.value);
|
||||
if (!isNaN(seasonIndex) && isFinite(seasonIndex)) {
|
||||
if (
|
||||
!Number.isNaN(seasonIndex) &&
|
||||
Number.isFinite(seasonIndex)
|
||||
) {
|
||||
setCurrentSeason(seasonIndex);
|
||||
sessionStorage.setItem(
|
||||
`season-${item.data?.Id}`,
|
||||
@@ -982,7 +974,7 @@ function SeriesTitlePage() {
|
||||
currentSubTrack="nosub"
|
||||
size="medium"
|
||||
buttonProps={{
|
||||
//@ts-ignore
|
||||
//@ts-expect-error
|
||||
color: "white",
|
||||
style: {
|
||||
color: "black ",
|
||||
|
||||
Reference in new issue
Block a user