Start Adding album card to ArtistPage #64
This commit is contained in:
2 files changed
+238
-1
No files matched your search
@@ -0,0 +1,159 @@
|
|||||||
|
/** @format */
|
||||||
|
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import Paper from "@mui/material/Paper";
|
||||||
|
import TableContainer from "@mui/material/TableContainer";
|
||||||
|
import Table from "@mui/material/Table";
|
||||||
|
import TableBody from "@mui/material/TableBody";
|
||||||
|
import TableHead from "@mui/material/TableHead";
|
||||||
|
import TableRow from "@mui/material/TableRow";
|
||||||
|
import TableCell from "@mui/material/TableCell";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
|
import { MdiClockOutline } from "../../icons/mdiClockOutline";
|
||||||
|
import { getRuntimeMusic } from "../../../utils/date/time";
|
||||||
|
import { MdiHeart } from "../../icons/mdiHeart";
|
||||||
|
import { MdiHeartOutline } from "../../icons/mdiHeartOutline";
|
||||||
|
|
||||||
|
export const ArtistAlbum = ({ user, album }) => {
|
||||||
|
const albumTracks = useQuery({
|
||||||
|
queryKey: ["artist", "album", album.Id],
|
||||||
|
queryFn: async () => {
|
||||||
|
const result = await getItemsApi(window.api).getItems({
|
||||||
|
userId: user.Id,
|
||||||
|
parentId: album.Id,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleLikingTrack = async (track) => {
|
||||||
|
let result;
|
||||||
|
if (track.UserData.IsFavorite) {
|
||||||
|
result = await getUserLibraryApi(window.api).unmarkFavoriteItem({
|
||||||
|
userId: user.data.Id,
|
||||||
|
itemId: track.Id,
|
||||||
|
});
|
||||||
|
} else if (!track.UserData.IsFavorite) {
|
||||||
|
result = await getUserLibraryApi(window.api).markFavoriteItem({
|
||||||
|
userId: user.data.Id,
|
||||||
|
itemId: track.Id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
albumTracks.refetch();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<Box></Box>
|
||||||
|
|
||||||
|
<TableContainer
|
||||||
|
component={Paper}
|
||||||
|
sx={{ mb: 2, borderRadius: "15px" }}
|
||||||
|
>
|
||||||
|
<Table>
|
||||||
|
<TableHead
|
||||||
|
sx={{
|
||||||
|
mb: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell
|
||||||
|
sx={{
|
||||||
|
maxWidth: 120,
|
||||||
|
width: 20,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography variant="h6">#</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell sx={{ width: 20 }}></TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Typography variant="h6">
|
||||||
|
Name
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Typography variant="h6" align="right">
|
||||||
|
<MdiClockOutline />
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableHead>
|
||||||
|
<TableBody>
|
||||||
|
{albumTracks.isSuccess &&
|
||||||
|
albumTracks.data.Items.map(
|
||||||
|
(mitem, mindex) => {
|
||||||
|
return (
|
||||||
|
<TableRow
|
||||||
|
key={mindex}
|
||||||
|
sx={{
|
||||||
|
"&:last-child td, &:last-child th":
|
||||||
|
{
|
||||||
|
border: 0,
|
||||||
|
},
|
||||||
|
"&:hover": {
|
||||||
|
background:
|
||||||
|
"rgb(255 255 255 / 0.05)",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TableCell
|
||||||
|
sx={{
|
||||||
|
maxWidth: 120,
|
||||||
|
width: 20,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography variant="body1">
|
||||||
|
{
|
||||||
|
mitem.IndexNumber
|
||||||
|
}
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell
|
||||||
|
sx={{
|
||||||
|
width: 20,
|
||||||
|
}}
|
||||||
|
align="center"
|
||||||
|
>
|
||||||
|
<IconButton
|
||||||
|
onClick={() =>
|
||||||
|
handleLikingTrack(
|
||||||
|
mitem,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{mitem.UserData
|
||||||
|
.IsFavorite ? (
|
||||||
|
<MdiHeart />
|
||||||
|
) : (
|
||||||
|
<MdiHeartOutline />
|
||||||
|
)}
|
||||||
|
</IconButton>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Typography variant="body1">
|
||||||
|
{mitem.Name}
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell align="right">
|
||||||
|
<Typography variant="body1">
|
||||||
|
{getRuntimeMusic(
|
||||||
|
mitem.RunTimeTicks,
|
||||||
|
)}
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</TableContainer>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -26,7 +26,7 @@ import MenuItem from "@mui/material/MenuItem";
|
|||||||
import Link from "@mui/material/Link";
|
import Link from "@mui/material/Link";
|
||||||
import { green, pink, yellow } from "@mui/material/colors";
|
import { green, pink, yellow } from "@mui/material/colors";
|
||||||
|
|
||||||
import { motion } from "framer-motion";
|
import { motion, useScroll } from "framer-motion";
|
||||||
|
|
||||||
import { Blurhash } from "react-blurhash";
|
import { Blurhash } from "react-blurhash";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
@@ -36,6 +36,7 @@ import {
|
|||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
ItemFields,
|
ItemFields,
|
||||||
MediaStreamType,
|
MediaStreamType,
|
||||||
|
SortOrder,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
@@ -64,6 +65,7 @@ import { CardScroller } from "../../components/cardScroller/cardScroller";
|
|||||||
import "./item.module.scss";
|
import "./item.module.scss";
|
||||||
import { EpisodeCardsSkeleton } from "../../components/skeleton/episodeCards";
|
import { EpisodeCardsSkeleton } from "../../components/skeleton/episodeCards";
|
||||||
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "../../components/notices/errorNotice/errorNotice";
|
||||||
|
import { ArtistAlbum } from "../../components/layouts/artist/artistAlbum";
|
||||||
function TabPanel(props) {
|
function TabPanel(props) {
|
||||||
const { children, value, index, ...other } = props;
|
const { children, value, index, ...other } = props;
|
||||||
|
|
||||||
@@ -300,6 +302,22 @@ const ItemDetail = () => {
|
|||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const artistDiscography = useQuery({
|
||||||
|
queryKey: ["item", id, "artist", "discography"],
|
||||||
|
queryFn: async () => {
|
||||||
|
const result = await getItemsApi(window.api).getItems({
|
||||||
|
albumArtistIds: [item.data.Id],
|
||||||
|
sortBy: ["PremiereDate", "ProductionYear", "SortName"],
|
||||||
|
sortOrder: [SortOrder.Descending],
|
||||||
|
recursive: true,
|
||||||
|
includeItemTypes: [BaseItemKind.MusicAlbum],
|
||||||
|
userId: user.data.Id,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
enabled: item.isSuccess && item.data.Type == BaseItemKind.MusicArtist,
|
||||||
|
});
|
||||||
|
|
||||||
const handleMarkPlayedOrunPlayed = async () => {
|
const handleMarkPlayedOrunPlayed = async () => {
|
||||||
let result;
|
let result;
|
||||||
if (!item.data.UserData.Played) {
|
if (!item.data.UserData.Played) {
|
||||||
@@ -379,6 +397,9 @@ const ItemDetail = () => {
|
|||||||
personEpisodes.isLoading,
|
personEpisodes.isLoading,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const artistTabs = ["Discography"];
|
||||||
|
const [activeArtistTab, setActiveArtistTab] = useState(0);
|
||||||
|
|
||||||
const [videoTracks, setVideoTracks] = useState([]);
|
const [videoTracks, setVideoTracks] = useState([]);
|
||||||
const [audioTracks, setAudioTracks] = useState([]);
|
const [audioTracks, setAudioTracks] = useState([]);
|
||||||
const [subtitleTracks, setSubtitleTracks] = useState([]);
|
const [subtitleTracks, setSubtitleTracks] = useState([]);
|
||||||
@@ -707,6 +728,9 @@ const ItemDetail = () => {
|
|||||||
opacity: 0.7,
|
opacity: 0.7,
|
||||||
}}
|
}}
|
||||||
color="inherit"
|
color="inherit"
|
||||||
|
key={
|
||||||
|
aindex
|
||||||
|
}
|
||||||
to={`/item/${artist.Id}`}
|
to={`/item/${artist.Id}`}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
@@ -2423,6 +2447,60 @@ const ItemDetail = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{item.data.Type == BaseItemKind.MusicArtist &&
|
||||||
|
artistDiscography.isSuccess && (
|
||||||
|
<Box>
|
||||||
|
<Tabs
|
||||||
|
value={activeArtistTab}
|
||||||
|
onChange={(e, newVal) =>
|
||||||
|
setActiveArtistTab(newVal)
|
||||||
|
}
|
||||||
|
aria-label="artists-tabs"
|
||||||
|
>
|
||||||
|
{artistTabs.map((pitem, index) => {
|
||||||
|
return (
|
||||||
|
<Tab
|
||||||
|
label={pitem}
|
||||||
|
{...a11yProps(
|
||||||
|
index,
|
||||||
|
)}
|
||||||
|
key={index}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Tabs>
|
||||||
|
{artistTabs.map((pitem, index) => {
|
||||||
|
return (
|
||||||
|
<TabPanel
|
||||||
|
value={activeArtistTab}
|
||||||
|
index={index}
|
||||||
|
key={index}
|
||||||
|
>
|
||||||
|
{pitem ==
|
||||||
|
"Discography" &&
|
||||||
|
artistDiscography.data.Items.map(
|
||||||
|
(album) => {
|
||||||
|
return (
|
||||||
|
<ArtistAlbum
|
||||||
|
key={
|
||||||
|
album.Id
|
||||||
|
}
|
||||||
|
user={
|
||||||
|
user.data
|
||||||
|
}
|
||||||
|
album={
|
||||||
|
album
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
</TabPanel>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
|
||||||
{item.data.People.length != 0 && (
|
{item.data.People.length != 0 && (
|
||||||
<CardScroller
|
<CardScroller
|
||||||
headingProps={{
|
headingProps={{
|
||||||
|
|||||||
Reference in new issue
Block a user