diff --git a/src/App.jsx b/src/App.jsx index 7174038..54b2e85 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -73,6 +73,7 @@ import { delUser, getUser } from "./utils/storage/user.js"; import axios from "axios"; import { useBackdropStore } from "./utils/store/backdrop.js"; import { usePlaybackDataLoadStore } from "./utils/store/playback.js"; +import BoxSetTitlePage from "./routes/boxset/index.jsx"; const jellyfin = new Jellyfin({ clientInfo: { @@ -398,12 +399,13 @@ function App() { opacity: 0, }} transition={{ - duration: 0.6, + duration: 0.5, + ease: "easeInOut", }} onLoad={() => setBackdropLoading(false)} loading="eager" style={{ - transition: "opacity 6s", + transition: "opacity 1s", }} /> @@ -467,8 +469,8 @@ function App() { /> } + path="/boxset/:id" + element={} /> {}} onClick + * @property {boolean} disableOverlay + * @property {boolean} disablePadding + * @property {any} overrideIcon + */ + +/** + * @description Hero section for item pages + * @param {Props} + * @returns {React.Component} + */ + +export const Card = ({ + item, + cardTitle, + cardCaption, + imageType = "Primary", + imageBlurhash, + cardType, + queryKey, + userId, + seriesId, + hideText, + onClick, + disableOverlay = false, + disablePadding, + overrideIcon, +}) => { + const navigate = useNavigate(); + const defaultOnClick = () => { + if (availableSpecialRoutes.includes(item.Type)) { + navigate(`/${item.Type.toLocaleLowerCase()}/${item.Id}`); + } else { + navigate(`/item/${item.Id}`); + } + }; + return ( + + +
+
+ {!!item.UserData && ( + <> +
+ +
+
+ + { + item.UserData + ?.UnplayedItemCount + } + +
+ + )} + {!!imageBlurhash && ( + + )} +
+ {!!overrideIcon + ? TypeIconCollectionCard[overrideIcon] + : TypeIconCollectionCard[item.Type]} +
+ (e.target.style.opacity = 1)} + className="card-image" + /> + {!disableOverlay && ( +
+ + + +
+ )} + {item.UserData?.PlaybackPositionTicks > 0 && ( + + )} +
+
+ + {cardTitle} + + + {cardCaption} + +
+
+
+
+ ); +}; diff --git a/src/components/card/card.jsx b/src/components/card/card.jsx index c2a8106..c62c4f3 100644 --- a/src/components/card/card.jsx +++ b/src/components/card/card.jsx @@ -25,7 +25,7 @@ const cardImageAspectRatios = { square: 1, }; -const availableSpecialRoutes = [BaseItemKind.Series]; +const availableSpecialRoutes = [BaseItemKind.Series, BaseItemKind.BoxSet]; /** * @typedef {Object} Props diff --git a/src/routes/collection/index.jsx b/src/routes/boxset/boxset.module.scss similarity index 100% rename from src/routes/collection/index.jsx rename to src/routes/boxset/boxset.module.scss diff --git a/src/routes/boxset/index.jsx b/src/routes/boxset/index.jsx new file mode 100644 index 0000000..82c48b7 --- /dev/null +++ b/src/routes/boxset/index.jsx @@ -0,0 +1,418 @@ +/** @format */ +import { useState, useEffect } from "react"; +import PropTypes from "prop-types"; + +import Box from "@mui/material/Box"; +import CircularProgress from "@mui/material/CircularProgress"; +import Typography from "@mui/material/Typography"; +import Stack from "@mui/material/Stack"; +import Chip from "@mui/material/Chip"; +import Divider from "@mui/material/Divider"; +import LinearProgress from "@mui/material/LinearProgress"; +import Tabs from "@mui/material/Tabs"; +import Tab from "@mui/material/Tab"; +import Grid2 from "@mui/material/Unstable_Grid2"; +import Button from "@mui/material/Button"; +import IconButton from "@mui/material/IconButton"; +import Paper from "@mui/material/Paper"; +import TableContainer from "@mui/material/TableContainer"; +import Table from "@mui/material/Table"; +import TableHead from "@mui/material/TableHead"; +import TableRow from "@mui/material/TableRow"; +import TableBody from "@mui/material/TableBody"; +import TableCell from "@mui/material/TableCell"; +import TextField from "@mui/material/TextField"; +import MenuItem from "@mui/material/MenuItem"; +import Link from "@mui/material/Link"; +import { green, pink, yellow } from "@mui/material/colors"; + +import { AnimatePresence, motion } from "framer-motion"; + +import { Blurhash } from "react-blurhash"; +import { useParams, useNavigate, Link as RouterLink } from "react-router-dom"; + +import { + BaseItemKind, + ItemFields, + LocationType, + MediaStreamType, + SortOrder, +} from "@jellyfin/sdk/lib/generated-client"; +import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; +import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api"; +import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api"; +import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api"; +import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api"; +import { getPlaystateApi } from "@jellyfin/sdk/lib/utils/api/playstate-api"; + +import { useQuery } from "@tanstack/react-query"; + +import { MdiPlayOutline } from "../../components/icons/mdiPlayOutline"; +import { MdiStar } from "../../components/icons/mdiStar"; +import { MdiCheck } from "../../components/icons/mdiCheck"; +import { MdiHeartOutline } from "../../components/icons/mdiHeartOutline"; +import { MdiHeart } from "../../components/icons/mdiHeart"; +import { MdiClockOutline } from "../../components/icons/mdiClockOutline"; + +import { getRuntimeMusic, getRuntimeFull, endsAt } from "../../utils/date/time"; +import { TypeIconCollectionCard } from "../../components/utils/iconsCollection"; + +import Hero from "../../components/layouts/item/hero"; +import { Card } from "../../components/card/card"; +import { EpisodeCard } from "../../components/card/episodeCard"; +import { CardScroller } from "../../components/cardScroller/cardScroller"; + +import "./boxset.module.scss"; +import { EpisodeCardsSkeleton } from "../../components/skeleton/episodeCards"; +import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice"; +import { ArtistAlbum } from "../../components/layouts/artist/artistAlbum"; +import { MdiMusic } from "../../components/icons/mdiMusic"; +import { usePlaybackStore } from "../../utils/store/playback"; +import { Tooltip } from "@mui/material"; +import { useBackdropStore } from "../../utils/store/backdrop"; +function TabPanel(props) { + const { children, value, index, ...other } = props; + + return ( + + ); +} + +TabPanel.propTypes = { + children: PropTypes.node, + index: PropTypes.number.isRequired, + value: PropTypes.number.isRequired, +}; + +function a11yProps(index) { + return { + id: `full-width-tab-${index}`, + "aria-controls": `full-width-tabpanel-${index}`, + }; +} + +const BoxSetTitlePage = () => { + const { id } = useParams(); + const navigate = useNavigate(); + + const user = useQuery({ + queryKey: ["user"], + queryFn: async () => { + let usr = await getUserApi(window.api).getCurrentUser(); + return usr.data; + }, + networkMode: "always", + }); + + const item = useQuery({ + queryKey: ["item", id], + queryFn: async () => { + const result = await getUserLibraryApi(window.api).getItem({ + userId: user.data.Id, + itemId: id, + fields: [ItemFields.Crew], + }); + return result.data; + }, + enabled: !!user.data, + networkMode: "always", + refetchOnWindowFocus: true, + }); + + const collectionItems = useQuery({ + queryKey: ["item", id, `collection`], + queryFn: async () => { + const result = await getItemsApi(window.api).getItems({ + userId: user.data.Id, + parentId: item.data.Id, + fields: [ItemFields.SeasonUserData, ItemFields.Overview], + excludeLocationTypes: [LocationType.Virtual], + }); + return result.data; + }, + enabled: item.isSuccess, + networkMode: "always", + refetchOnWindowFocus: true, + }); + + const similarItems = useQuery({ + queryKey: ["item", id, "similarItem"], + queryFn: async () => { + let result; + if (item.data.Type == "Movie") { + result = await getLibraryApi(window.api).getSimilarMovies({ + userId: user.data.Id, + itemId: item.data.Id, + }); + } else if (item.data.Type == "Series") { + result = await getLibraryApi(window.api).getSimilarShows({ + userId: user.data.Id, + itemId: item.data.Id, + }); + } else if (item.data.Type == "MusicAlbum") { + result = await getLibraryApi(window.api).getSimilarAlbums({ + userId: user.data.Id, + itemId: item.data.Id, + }); + } else if (item.data.Type == "MusicArtist") { + result = await getLibraryApi(window.api).getSimilarArtists({ + userId: user.data.Id, + itemId: item.data.Id, + }); + } else { + result = await getLibraryApi(window.api).getSimilarItems({ + userId: user.data.Id, + itemId: item.data.Id, + }); + } + return result.data; + }, + enabled: item.isSuccess, + networkMode: "always", + refetchOnWindowFocus: true, + }); + + const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]); + + const [directors, setDirectors] = useState([]); + const [writers, setWriters] = useState([]); + useEffect(() => { + if (item.isSuccess) { + setAppBackdrop( + item.data.Type === BaseItemKind.MusicAlbum || + item.data.Type === BaseItemKind.Episode + ? `${window.api.basePath}/Items/${item.data.ParentBackdropItemId}/Images/Backdrop` + : `${window.api.basePath}/Items/${item.data.Id}/Images/Backdrop`, + item.data.Id, + ); + let direTp = item.data.People.filter( + (itm) => itm.Type == "Director", + ); + setDirectors(direTp); + let writeTp = item.data.People.filter( + (itm) => itm.Type == "Writer", + ); + setWriters(writeTp); + } + }, [item.isSuccess]); + + if (item.isLoading || similarItems.isLoading) { + return ( + + + + ); + } + if (item.isSuccess && similarItems.isSuccess) { + return ( +
+ + {item.data.People.length > 0 && ( + + {item.data.People.map((person, index) => { + return ( + + ); + })} + + )} + {collectionItems.data.TotalRecordCount > 0 && ( + + {collectionItems.data.Items.map( + (similar, index) => { + return ( + + ); + }, + )} + + )} + {similarItems.data.TotalRecordCount > 0 && ( + + {similarItems.data.Items.map((similar, index) => { + return ( + + ); + })} + + )} +
+ ); + } + if (item.isError || similarItems.isError) { + return ; + } +}; + +export default BoxSetTitlePage; diff --git a/src/routes/library/index.jsx b/src/routes/library/index.jsx index 87144a6..2818a6b 100644 --- a/src/routes/library/index.jsx +++ b/src/routes/library/index.jsx @@ -1035,16 +1035,16 @@ const LibraryView = () => { ], ]} userId={user.data.Id} - imageBlurhash={ - item.ImageBlurHashes - ?.Primary[ - Object.keys( - item - .ImageBlurHashes - .Primary, - )[0] - ] - } + // imageBlurhash={ + // item.ImageBlurHashes + // ?.Primary[ + // Object.keys( + // item + // .ImageBlurHashes + // .Primary, + // )[0] + // ] + // } > ); diff --git a/src/routes/series/index.jsx b/src/routes/series/index.jsx index 5b7b06a..a87d990 100644 --- a/src/routes/series/index.jsx +++ b/src/routes/series/index.jsx @@ -205,7 +205,7 @@ const SeriesTitlePage = () => { userId: user.data.Id, seriesId: item.data.Id, seasonId: seasons.data.Items[currentSeason].Id, - fields: [ItemFields.SeasonUserData, "Overview"], + fields: [ItemFields.SeasonUserData, ItemFields.Overview], excludeLocationTypes: [LocationType.Virtual], }); return result.data; @@ -317,7 +317,7 @@ const SeriesTitlePage = () => { return ( { duration: 0.2, ease: "backInOut", }} + style={{ + maxWidth: + "23.3vw", + }} >