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