Add liking and watched status marking for seasons
This commit is contained in:
6 files changed
+259
-223
No files matched your search
+11
-4
@@ -437,19 +437,26 @@ function App() {
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
opacity: backdropLoading ? 0 : 0.5,
|
||||
opacity: backdropLoading ? 0 : 0.6,
|
||||
}}
|
||||
exit={{
|
||||
opacity: 0,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.5,
|
||||
duration: 0.8,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
onLoad={() => setBackdropLoading(false)}
|
||||
onLoadCapture={() => {
|
||||
console.log(`loading ${backdropId}`);
|
||||
setBackdropLoading(true);
|
||||
}}
|
||||
onLoad={() => {
|
||||
console.log(`loaded ${backdropId}`);
|
||||
setBackdropLoading(false);
|
||||
}}
|
||||
loading="eager"
|
||||
style={{
|
||||
transition: "opacity 1s",
|
||||
transition: "opacity 0.8s",
|
||||
}}
|
||||
/>
|
||||
</AnimatePresence>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/** @format */
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import React from "react";
|
||||
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
|
||||
@@ -25,14 +25,13 @@ const LikeButton = ({
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const handleLiking = async () => {
|
||||
let result;
|
||||
if (isFavorite) {
|
||||
result = await getUserLibraryApi(window.api).unmarkFavoriteItem({
|
||||
await getUserLibraryApi(window.api).unmarkFavoriteItem({
|
||||
userId: userId,
|
||||
itemId: itemId,
|
||||
});
|
||||
} else if (!isFavorite) {
|
||||
result = await getUserLibraryApi(window.api).markFavoriteItem({
|
||||
await getUserLibraryApi(window.api).markFavoriteItem({
|
||||
userId: userId,
|
||||
itemId: itemId,
|
||||
});
|
||||
@@ -40,7 +39,7 @@ const LikeButton = ({
|
||||
};
|
||||
const mutation = useMutation({
|
||||
mutationFn: handleLiking,
|
||||
onError: (error, a, context) => {
|
||||
onError: (error) => {
|
||||
enqueueSnackbar(`${error}`, {
|
||||
variant: "error",
|
||||
});
|
||||
|
||||
@@ -59,7 +59,7 @@ const CarouselSlide = ({ item }) => {
|
||||
const handleMoreInfo = () => {
|
||||
if (availableSpecialRoutes.includes(item.Type)) {
|
||||
navigate(`/${item.Type.toLocaleLowerCase()}/${item.Id}`);
|
||||
} else if (!!item.Role) {
|
||||
} else if (item.Role) {
|
||||
navigate(`/person/${item.Id}`);
|
||||
} else {
|
||||
navigate(`/item/${item.Id}`);
|
||||
@@ -106,7 +106,7 @@ const CarouselSlide = ({ item }) => {
|
||||
<img
|
||||
className="hero-carousel-background-image"
|
||||
src={
|
||||
!!item.ParentBackdropItemId
|
||||
item.ParentBackdropItemId
|
||||
? `${window.api.basePath}/Items/${item.ParentBackdropItemId}/Images/Backdrop`
|
||||
: `${window.api.basePath}/Items/${item.Id}/Images/Backdrop`
|
||||
}
|
||||
@@ -128,8 +128,8 @@ const CarouselSlide = ({ item }) => {
|
||||
initial={{
|
||||
transform:
|
||||
animationDirection == "right"
|
||||
? "translateX(40px)"
|
||||
: "translateX(-40px)",
|
||||
? "translateX(60px)"
|
||||
: "translateX(-60px)",
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{
|
||||
@@ -139,8 +139,8 @@ const CarouselSlide = ({ item }) => {
|
||||
exit={{
|
||||
transform:
|
||||
animationDirection == "right"
|
||||
? "translateX(-40px)"
|
||||
: "translateX(40px)",
|
||||
? "translateX(-60px)"
|
||||
: "translateX(60px)",
|
||||
|
||||
opacity: 0,
|
||||
}}
|
||||
@@ -199,7 +199,7 @@ const CarouselSlide = ({ item }) => {
|
||||
className="hero-carousel-info"
|
||||
>
|
||||
<Typography variant="subtitle1">
|
||||
{!!item.ProductionYear
|
||||
{item.ProductionYear
|
||||
? item.ProductionYear
|
||||
: "Unknown"}
|
||||
</Typography>
|
||||
@@ -215,7 +215,7 @@ const CarouselSlide = ({ item }) => {
|
||||
}}
|
||||
className="hero-carousel-info-rating"
|
||||
>
|
||||
{!!item.CommunityRating ? (
|
||||
{item.CommunityRating ? (
|
||||
<>
|
||||
<MdiStar
|
||||
sx={{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** @format */
|
||||
import { useState, useEffect } from "react";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import Box from "@mui/material/Box";
|
||||
@@ -279,7 +279,6 @@ const PersonTitlePage = () => {
|
||||
queryKey={["item", id]}
|
||||
disableInfoStrip
|
||||
disablePlayButton
|
||||
disableLikeButton
|
||||
disableMarkAsPlayedButton
|
||||
/>
|
||||
<div className="item-detail-person-container">
|
||||
|
||||
+234
-203
@@ -1,5 +1,5 @@
|
||||
/** @format */
|
||||
import { useState, useEffect } from "react";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import Box from "@mui/material/Box";
|
||||
@@ -12,7 +12,7 @@ import MenuItem from "@mui/material/MenuItem";
|
||||
|
||||
import { motion } from "framer-motion";
|
||||
|
||||
import { useParams, useNavigate, Link as RouterLink } from "react-router-dom";
|
||||
import { useParams } from "react-router-dom";
|
||||
|
||||
import {
|
||||
BaseItemKind,
|
||||
@@ -26,7 +26,7 @@ import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { getRuntimeMusic, getRuntimeFull, endsAt } from "../../utils/date/time";
|
||||
import { getRuntimeMusic } from "../../utils/date/time";
|
||||
|
||||
import Hero from "../../components/layouts/item/hero";
|
||||
import { Card } from "../../components/card/card";
|
||||
@@ -36,12 +36,12 @@ import { CardScroller } from "../../components/cardScroller/cardScroller";
|
||||
import "./series.module.scss";
|
||||
import { EpisodeCardsSkeleton } from "../../components/skeleton/episodeCards";
|
||||
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
|
||||
import { usePlaybackStore } from "../../utils/store/playback";
|
||||
|
||||
import { useBackdropStore } from "../../utils/store/backdrop";
|
||||
import { ActorCard } from "../../components/card/actorCards";
|
||||
import { SeasonSelectorSkeleton } from "../../components/skeleton/seasonSelector";
|
||||
import { stagger } from "framer-motion";
|
||||
import LikeButton from "../../components/buttons/likeButton";
|
||||
import MarkPlayedButton from "../../components/buttons/markPlayedButton";
|
||||
function TabPanel(props) {
|
||||
const { children, value, index, ...other } = props;
|
||||
|
||||
@@ -65,16 +65,8 @@ TabPanel.propTypes = {
|
||||
value: PropTypes.number.isRequired,
|
||||
};
|
||||
|
||||
function a11yProps(index) {
|
||||
return {
|
||||
id: `full-width-tab-${index}`,
|
||||
"aria-controls": `full-width-tabpanel-${index}`,
|
||||
};
|
||||
}
|
||||
|
||||
const SeriesTitlePage = () => {
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
@@ -148,6 +140,21 @@ const SeriesTitlePage = () => {
|
||||
});
|
||||
|
||||
const [currentSeason, setCurrentSeason] = useState(0);
|
||||
|
||||
const currentSeasonItem = useQuery({
|
||||
queryKey: ["item", id, "season", currentSeason],
|
||||
queryFn: async () => {
|
||||
const result = await getUserLibraryApi(window.api).getItem({
|
||||
userId: user.data.Id,
|
||||
itemId: seasons.data.Items[currentSeason].Id,
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: seasons.isSuccess,
|
||||
networkMode: "always",
|
||||
refetchOnWindowFocus: true,
|
||||
});
|
||||
|
||||
const episodes = useQuery({
|
||||
queryKey: ["item", id, `season ${currentSeason + 1}`, "episodes"],
|
||||
queryFn: async () => {
|
||||
@@ -178,24 +185,6 @@ const SeriesTitlePage = () => {
|
||||
},
|
||||
enabled: item.isSuccess,
|
||||
});
|
||||
const [
|
||||
setUrl,
|
||||
setPosition,
|
||||
setDuration,
|
||||
setItemId,
|
||||
setItemName,
|
||||
setSubtitleTracksStore,
|
||||
setSelectedSubtitleTrack,
|
||||
] = usePlaybackStore((state) => [
|
||||
state.setUrl,
|
||||
state.setPosition,
|
||||
state.setDuration,
|
||||
state.setItemId,
|
||||
state.setItemName,
|
||||
state.setSubtitleTracks,
|
||||
state.setSelectedSubtitleTrack,
|
||||
]);
|
||||
|
||||
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
||||
|
||||
const [directors, setDirectors] = useState([]);
|
||||
@@ -262,40 +251,35 @@ const SeriesTitlePage = () => {
|
||||
displayCards={4}
|
||||
disableDecoration
|
||||
>
|
||||
{nextUpEpisode.data.Items.map(
|
||||
(episode, index) => {
|
||||
return (
|
||||
<EpisodeCard
|
||||
item={episode}
|
||||
cardTitle={`S${episode.ParentIndexNumber}:E${episode.IndexNumber} - ${episode.Name}`}
|
||||
cardCaption={
|
||||
episode.Overview
|
||||
}
|
||||
imageBlurhash={
|
||||
episode
|
||||
.ImageBlurHashes
|
||||
?.Primary[
|
||||
Object.keys(
|
||||
episode
|
||||
.ImageBlurHashes
|
||||
.Primary,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
queryKey={[
|
||||
"item",
|
||||
id,
|
||||
`season ${
|
||||
currentSeason +
|
||||
1
|
||||
}`,
|
||||
"episodes",
|
||||
]}
|
||||
userId={user.data.Id}
|
||||
/>
|
||||
);
|
||||
},
|
||||
)}
|
||||
{nextUpEpisode.data.Items.map((episode) => {
|
||||
return (
|
||||
<EpisodeCard
|
||||
key={episode.Id}
|
||||
item={episode}
|
||||
cardTitle={`S${episode.ParentIndexNumber}:E${episode.IndexNumber} - ${episode.Name}`}
|
||||
cardCaption={episode.Overview}
|
||||
imageBlurhash={
|
||||
episode.ImageBlurHashes
|
||||
?.Primary[
|
||||
Object.keys(
|
||||
episode
|
||||
.ImageBlurHashes
|
||||
.Primary,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
queryKey={[
|
||||
"item",
|
||||
id,
|
||||
`season ${
|
||||
currentSeason + 1
|
||||
}`,
|
||||
"episodes",
|
||||
]}
|
||||
userId={user.data.Id}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</CardScroller>
|
||||
)}
|
||||
|
||||
@@ -345,110 +329,163 @@ const SeriesTitlePage = () => {
|
||||
}
|
||||
></Chip>
|
||||
</div>
|
||||
<TextField
|
||||
value={currentSeason}
|
||||
onChange={(e) =>
|
||||
setCurrentSeason(e.target.value)
|
||||
}
|
||||
select
|
||||
SelectProps={{
|
||||
MenuProps: {
|
||||
disableScrollLock: true,
|
||||
},
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.75em",
|
||||
}}
|
||||
size="small"
|
||||
>
|
||||
{seasons.data.Items.map(
|
||||
(season, index) => {
|
||||
return (
|
||||
<MenuItem
|
||||
key={season.Id}
|
||||
value={index}
|
||||
>
|
||||
{season.Name}
|
||||
</MenuItem>
|
||||
);
|
||||
},
|
||||
{currentSeasonItem.isSuccess && (
|
||||
<LikeButton
|
||||
itemId={
|
||||
currentSeasonItem.data.Id
|
||||
}
|
||||
isFavorite={
|
||||
currentSeasonItem.data
|
||||
.UserData.IsFavorite
|
||||
}
|
||||
queryKey={[
|
||||
"item",
|
||||
id,
|
||||
"season",
|
||||
currentSeason,
|
||||
]}
|
||||
userId={user.data.Id}
|
||||
itemName={
|
||||
currentSeasonItem.data
|
||||
.Name
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</TextField>
|
||||
{currentSeasonItem.isSuccess && (
|
||||
<>
|
||||
<MarkPlayedButton
|
||||
itemId={
|
||||
currentSeasonItem
|
||||
.data.Id
|
||||
}
|
||||
isPlayed={
|
||||
currentSeasonItem
|
||||
.data.UserData
|
||||
.Played
|
||||
}
|
||||
queryKey={[
|
||||
"item",
|
||||
id,
|
||||
"season",
|
||||
currentSeason,
|
||||
]}
|
||||
userId={user.data.Id}
|
||||
itemName={
|
||||
currentSeasonItem
|
||||
.data.Name
|
||||
}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<TextField
|
||||
value={currentSeason}
|
||||
onChange={(e) =>
|
||||
setCurrentSeason(
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
select
|
||||
SelectProps={{
|
||||
MenuProps: {
|
||||
disableScrollLock: true,
|
||||
},
|
||||
}}
|
||||
size="small"
|
||||
>
|
||||
{seasons.data.Items.map(
|
||||
(season, index) => {
|
||||
return (
|
||||
<MenuItem
|
||||
key={season.Id}
|
||||
value={index}
|
||||
>
|
||||
{season.Name}
|
||||
</MenuItem>
|
||||
);
|
||||
},
|
||||
)}
|
||||
</TextField>
|
||||
</div>
|
||||
</div>
|
||||
<Divider />
|
||||
<div className="item-detail-episodes-container">
|
||||
{episodes.isLoading ? (
|
||||
<EpisodeCardsSkeleton />
|
||||
) : (
|
||||
episodes.data.Items.map(
|
||||
(episode, index) => {
|
||||
return (
|
||||
<motion.div
|
||||
key={episode.Id}
|
||||
initial={{
|
||||
transform:
|
||||
"translateY(10px)",
|
||||
opacity: 0,
|
||||
}}
|
||||
whileInView={{
|
||||
opacity: 1,
|
||||
transform:
|
||||
"translateY(0px)",
|
||||
}}
|
||||
viewport={{
|
||||
once: true,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.2,
|
||||
ease: "backInOut",
|
||||
}}
|
||||
style={{
|
||||
maxWidth:
|
||||
"23.3vw",
|
||||
}}
|
||||
>
|
||||
<EpisodeCard
|
||||
item={episode}
|
||||
cardTitle={
|
||||
episode.ParentIndexNumber ==
|
||||
0
|
||||
? `${episode.SeasonName} - ${episode.Name}`
|
||||
: !!episode.IndexNumberEnd
|
||||
? `${episode.IndexNumber}-${episode.IndexNumberEnd}. ${episode.Name}`
|
||||
: `${episode.IndexNumber}. ${episode.Name}`
|
||||
}
|
||||
cardCaption={
|
||||
episode.Overview
|
||||
}
|
||||
imageBlurhash={
|
||||
!!episode
|
||||
.ImageBlurHashes
|
||||
?.Primary &&
|
||||
episode
|
||||
.ImageBlurHashes
|
||||
?.Primary[
|
||||
Object.keys(
|
||||
episode
|
||||
.ImageBlurHashes
|
||||
.Primary,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
queryKey={[
|
||||
"item",
|
||||
id,
|
||||
`season ${
|
||||
currentSeason +
|
||||
1
|
||||
}`,
|
||||
"episodes",
|
||||
]}
|
||||
userId={
|
||||
user.data
|
||||
.Id
|
||||
}
|
||||
/>
|
||||
</motion.div>
|
||||
);
|
||||
},
|
||||
)
|
||||
episodes.data.Items.map((episode) => {
|
||||
return (
|
||||
<motion.div
|
||||
key={episode.Id}
|
||||
initial={{
|
||||
transform:
|
||||
"translateY(10px)",
|
||||
opacity: 0,
|
||||
}}
|
||||
whileInView={{
|
||||
opacity: 1,
|
||||
transform:
|
||||
"translateY(0px)",
|
||||
}}
|
||||
viewport={{
|
||||
once: true,
|
||||
}}
|
||||
transition={{
|
||||
duration: 0.2,
|
||||
ease: "backInOut",
|
||||
}}
|
||||
style={{
|
||||
maxWidth: "23.3vw",
|
||||
}}
|
||||
>
|
||||
<EpisodeCard
|
||||
item={episode}
|
||||
cardTitle={
|
||||
episode.ParentIndexNumber ==
|
||||
0
|
||||
? `${episode.SeasonName} - ${episode.Name}`
|
||||
: episode.IndexNumberEnd
|
||||
? `${episode.IndexNumber}-${episode.IndexNumberEnd}. ${episode.Name}`
|
||||
: `${episode.IndexNumber}. ${episode.Name}`
|
||||
}
|
||||
cardCaption={
|
||||
episode.Overview
|
||||
}
|
||||
imageBlurhash={
|
||||
!!episode
|
||||
.ImageBlurHashes
|
||||
?.Primary &&
|
||||
episode
|
||||
.ImageBlurHashes
|
||||
?.Primary[
|
||||
Object.keys(
|
||||
episode
|
||||
.ImageBlurHashes
|
||||
.Primary,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
queryKey={[
|
||||
"item",
|
||||
id,
|
||||
`season ${
|
||||
currentSeason +
|
||||
1
|
||||
}`,
|
||||
"episodes",
|
||||
]}
|
||||
userId={
|
||||
user.data.Id
|
||||
}
|
||||
/>
|
||||
</motion.div>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -460,46 +497,40 @@ const SeriesTitlePage = () => {
|
||||
displayCards={8}
|
||||
disableDecoration
|
||||
>
|
||||
{specialFeatures.data.map(
|
||||
(special, index) => {
|
||||
return (
|
||||
<Card
|
||||
key={special.Id}
|
||||
item={special}
|
||||
seriesId={
|
||||
special.SeriesId
|
||||
}
|
||||
cardTitle={special.Name}
|
||||
imageType="Primary"
|
||||
cardCaption={getRuntimeMusic(
|
||||
special.RunTimeTicks,
|
||||
)}
|
||||
cardType="portrait"
|
||||
queryKey={[
|
||||
"item",
|
||||
id,
|
||||
"similarItem",
|
||||
]}
|
||||
imageBlurhash={
|
||||
!!special
|
||||
.ImageBlurHashes
|
||||
?.Primary &&
|
||||
special
|
||||
.ImageBlurHashes
|
||||
.Primary[
|
||||
Object.keys(
|
||||
special
|
||||
.ImageBlurHashes
|
||||
.Primary,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
userId={user.data.Id}
|
||||
onClick={() => {}}
|
||||
/>
|
||||
);
|
||||
},
|
||||
)}
|
||||
{specialFeatures.data.map((special) => {
|
||||
return (
|
||||
<Card
|
||||
key={special.Id}
|
||||
item={special}
|
||||
seriesId={special.SeriesId}
|
||||
cardTitle={special.Name}
|
||||
imageType="Primary"
|
||||
cardCaption={getRuntimeMusic(
|
||||
special.RunTimeTicks,
|
||||
)}
|
||||
cardType="portrait"
|
||||
queryKey={[
|
||||
"item",
|
||||
id,
|
||||
"similarItem",
|
||||
]}
|
||||
imageBlurhash={
|
||||
!!special.ImageBlurHashes
|
||||
?.Primary &&
|
||||
special.ImageBlurHashes
|
||||
.Primary[
|
||||
Object.keys(
|
||||
special
|
||||
.ImageBlurHashes
|
||||
.Primary,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
userId={user.data.Id}
|
||||
onClick={() => {}}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</CardScroller>
|
||||
)}
|
||||
{item.data.People.length > 0 && (
|
||||
@@ -508,7 +539,7 @@ const SeriesTitlePage = () => {
|
||||
displayCards={8}
|
||||
disableDecoration
|
||||
>
|
||||
{item.data.People.map((person, index) => {
|
||||
{item.data.People.map((person) => {
|
||||
return (
|
||||
<ActorCard
|
||||
key={person.Id}
|
||||
@@ -534,7 +565,7 @@ const SeriesTitlePage = () => {
|
||||
displayCards={8}
|
||||
disableDecoration
|
||||
>
|
||||
{similarItems.data.Items.map((similar, index) => {
|
||||
{similarItems.data.Items.map((similar) => {
|
||||
return (
|
||||
<Card
|
||||
key={similar.Id}
|
||||
@@ -556,7 +587,7 @@ const SeriesTitlePage = () => {
|
||||
? `${
|
||||
similar.ProductionYear
|
||||
} - ${
|
||||
!!similar.EndDate
|
||||
similar.EndDate
|
||||
? new Date(
|
||||
similar.EndDate,
|
||||
).toLocaleString(
|
||||
|
||||
@@ -50,7 +50,7 @@ body {
|
||||
top: -100px;
|
||||
left: -100px;
|
||||
z-index: -1;
|
||||
filter: blur(100px) saturate(120%) contrast(90%);
|
||||
filter: blur(120px) saturate(130%) contrast(140%);
|
||||
&-container {
|
||||
position: fixed;
|
||||
width: 100vw;
|
||||
|
||||
Reference in new issue
Block a user