From ee6b976e84a5b2d9e49abd40c15dacc4a27cb48c Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Tue, 12 Sep 2023 16:09:13 +0530 Subject: [PATCH] Add season component #160 --- src/components/card/card.jsx | 31 +---- src/components/card/card.module.scss | 13 ++ src/components/layouts/item/hero.jsx | 6 +- src/routes/series/index.jsx | 183 ++++++++++++++++++++------- 4 files changed, 159 insertions(+), 74 deletions(-) diff --git a/src/components/card/card.jsx b/src/components/card/card.jsx index 1d2c256..5208c78 100644 --- a/src/components/card/card.jsx +++ b/src/components/card/card.jsx @@ -3,7 +3,6 @@ import PropTypes from "prop-types"; import { useNavigate } from "react-router-dom"; -import Stack from "@mui/material/Stack"; import MuiCard from "@mui/material/Card"; import CardActionArea from "@mui/material/CardActionArea"; import Typography from "@mui/material/Typography"; @@ -78,31 +77,15 @@ export const Card = ({ }; return ( - - + +
- +
); diff --git a/src/components/card/card.module.scss b/src/components/card/card.module.scss index fd73578..6648a2c 100644 --- a/src/components/card/card.module.scss +++ b/src/components/card/card.module.scss @@ -1,5 +1,18 @@ /** @format */ .card { + height: 100%; + overflow: visible !important; + align-items: flex-start; + background: transparent !important; + &-box { + display: flex; + width: 100%; + height: 100%; + position: relative; + overflow: visible; + flex-direction: column; + justify-content: center; + } &-image { width: 100%; height: 100%; diff --git a/src/components/layouts/item/hero.jsx b/src/components/layouts/item/hero.jsx index ee6d4e6..8dd64dd 100644 --- a/src/components/layouts/item/hero.jsx +++ b/src/components/layouts/item/hero.jsx @@ -75,9 +75,9 @@ const Hero = ({ filterMediaStreamSubtitle, ); - const [currentVideoIndex, setCurrentVideoIndex] = useState(""); - const [currentAudioIndex, setCurrentAudioIndex] = useState(""); - const [currentSubtitleIndex, setCurrentSubtitleIndex] = useState(""); + const [currentVideoIndex, setCurrentVideoIndex] = useState(0); + const [currentAudioIndex, setCurrentAudioIndex] = useState(0); + const [currentSubtitleIndex, setCurrentSubtitleIndex] = useState(0); useEffect(() => { if (!!videoTracks && !!audioTracks & !!subtitleTracks) { diff --git a/src/routes/series/index.jsx b/src/routes/series/index.jsx index 5d44c77..fd790b9 100644 --- a/src/routes/series/index.jsx +++ b/src/routes/series/index.jsx @@ -169,12 +169,13 @@ const SeriesTitlePage = () => { queryKey: ["item", id, "seasons"], queryFn: async () => { const result = await getTvShowsApi(window.api).getSeasons({ + userId: user.data.Id, seriesId: item.data.Id, isSpecialSeason: false, }); return result.data; }, - enabled: item.isSuccess && item.data.Type == "Series", + enabled: item.isSuccess, networkMode: "always", refetchOnWindowFocus: true, }); @@ -199,9 +200,10 @@ const SeriesTitlePage = () => { const episodes = useQuery({ queryKey: ["item", id, `season ${currentSeason + 1}`, "episodes"], queryFn: async () => { - const result = await getItemsApi(window.api).getItems({ + const result = await getTvShowsApi(window.api).getEpisodes({ userId: user.data.Id, - parentId: seasons.data.Items[currentSeason].Id, + seriesId: item.data.Id, + seasonId: seasons.data.Items[currentSeason].Id, fields: [ItemFields.SeasonUserData, "Overview"], excludeLocationTypes: [LocationType.Virtual], }); @@ -212,47 +214,19 @@ const SeriesTitlePage = () => { refetchOnWindowFocus: true, }); - const [videoTracks, setVideoTracks] = useState([]); - const [audioTracks, setAudioTracks] = useState([]); - const [subtitleTracks, setSubtitleTracks] = useState([]); - - const filterMediaStreamVideo = (source) => { - if (source.Type == MediaStreamType.Video) { - return true; - } - return false; - }; - const filterMediaStreamAudio = (source) => { - if (source.Type == MediaStreamType.Audio) { - return true; - } - return false; - }; - const filterMediaStreamSubtitle = (source) => { - if (source.Type == MediaStreamType.Subtitle) { - return true; - } - return false; - }; - - useEffect(() => { - if (item.isSuccess && !!item.data.MediaStreams) { - let videos = item.data.MediaStreams.filter( - filterMediaStreamVideo, - ); - let audios = item.data.MediaStreams.filter( - filterMediaStreamAudio, - ); - let subs = item.data.MediaStreams.filter( - filterMediaStreamSubtitle, - ); - - setVideoTracks(videos); - setAudioTracks(audios); - setSubtitleTracks(subs); - } - }, [item.isSuccess]); - + const specialFeatures = useQuery({ + queryKey: ["item", id, `specialFeatures`], + queryFn: async () => { + const result = await getUserLibraryApi( + window.api, + ).getSpecialFeatures({ + itemId: item.data.Id, + userId: user.data.Id, + }); + return result.data; + }, + enabled: item.isSuccess, + }); const [ setUrl, setPosition, @@ -327,9 +301,6 @@ const SeriesTitlePage = () => { queryKey={["item", id]} writers={writers} directors={directors} - videoTracks={videoTracks} - audioTracks={audioTracks} - subtitleTracks={subtitleTracks} /> {nextUpEpisode.isSuccess && nextUpEpisode.data.TotalRecordCount > 0 && ( @@ -396,6 +367,124 @@ const SeriesTitlePage = () => { )} + {seasons.isSuccess && ( +
+
+
+ + { + seasons.data.Items[ + currentSeason + ].Name + } + + + ) : ( + episodes.data + .TotalRecordCount + ) + } + > +
+ + setCurrentSeason(e.target.value) + } + select + SelectProps={{ + MenuProps: { + disableScrollLock: true, + }, + }} + size="small" + > + {seasons.data.Items.map( + (season, index) => { + return ( + + {season.Name} + + ); + }, + )} + +
+ +
+ )} + {specialFeatures.isSuccess && + specialFeatures.data.length > 0 && ( + + {specialFeatures.data.map( + (special, index) => { + return ( + {}} + /> + ); + }, + )} + + )}