refactore: move more components to typescript
This commit is contained in:
14 files changed
+544
-682
No files matched your search
@@ -0,0 +1,60 @@
|
||||
.item-info-track{
|
||||
display: grid;
|
||||
grid-template-columns: 3em 60% 6em 1fr;
|
||||
gap: 1em;
|
||||
padding: 1em;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
border-radius: $border-radius-default;
|
||||
transition: background $transition-time-fast;
|
||||
&.header {
|
||||
border-bottom: 1px solid rgb(255 255 255 / 0.2);
|
||||
color: rgb(255 255 255 / 0.7);
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
.index-container {
|
||||
justify-self: center;
|
||||
position: relative;
|
||||
.material-symbols-rounded {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
font-size: 2em !important;
|
||||
opacity: 0;
|
||||
transition: none !important;
|
||||
color: $clr-accent-default;
|
||||
}
|
||||
}
|
||||
&-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.1em
|
||||
}
|
||||
&:hover {
|
||||
background: rgb(255 255 255 / 0.1) !important;
|
||||
.index-container {
|
||||
// font-size: 0em;
|
||||
.index {
|
||||
opacity: 0;
|
||||
transition: opacity 0;
|
||||
}
|
||||
.material-symbols-rounded {
|
||||
opacity: 1;
|
||||
font-size: 2.2em !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.playing {
|
||||
background: rgb(0 0 0 / 0.4) !important;
|
||||
.item-info-track-info-name, .index {
|
||||
color: $clr-accent-default;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
&-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4em
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import {
|
||||
generateAudioStreamUrl,
|
||||
playAudio,
|
||||
useAudioPlayback,
|
||||
} from "@/utils/store/audioPlayback";
|
||||
import type {
|
||||
BaseItemDto,
|
||||
BaseItemDtoQueryResult,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { Typography } from "@mui/material";
|
||||
import React from "react";
|
||||
|
||||
import { getRuntimeMusic } from "@/utils/date/time";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { setQueue } from "@/utils/store/queue";
|
||||
import { useSnackbar } from "notistack";
|
||||
import lyricsIcon from "../../assets/icons/lyrics.svg";
|
||||
import LikeButton from "../buttons/likeButton";
|
||||
|
||||
import "./albumMusicTrack.scss";
|
||||
|
||||
type AlbumMusicTrackProps = {
|
||||
track: BaseItemDto;
|
||||
/**
|
||||
* This is the index of the track in the musicTracks array (not to be confused with IndexNumber property of the track)
|
||||
*/
|
||||
trackIndex: number;
|
||||
musicTracks: BaseItemDtoQueryResult | null;
|
||||
};
|
||||
|
||||
export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
||||
const { track, musicTracks, trackIndex } = props;
|
||||
const [currentPlayingItem] = useAudioPlayback((state) => [state.item]);
|
||||
|
||||
const user = useCentralStore((state) => state.currentUser);
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const handlePlayback = (
|
||||
index: number,
|
||||
item: BaseItemDto,
|
||||
queue: BaseItemDto[],
|
||||
) => {
|
||||
if (!user?.Id || !api) {
|
||||
console.error("User not logged in");
|
||||
enqueueSnackbar("You need to be logged in to play music", {
|
||||
variant: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (item.Id) {
|
||||
const url = generateAudioStreamUrl(
|
||||
item.Id,
|
||||
user.Id,
|
||||
api.deviceInfo.id,
|
||||
api.basePath,
|
||||
api.accessToken,
|
||||
);
|
||||
playAudio(url, item);
|
||||
setQueue(queue, index);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div
|
||||
className={
|
||||
currentPlayingItem?.Id === track.Id
|
||||
? "item-info-track playing"
|
||||
: "item-info-track"
|
||||
}
|
||||
key={track.Id}
|
||||
onClick={() => {
|
||||
if (musicTracks?.Items) {
|
||||
handlePlayback(trackIndex, track, musicTracks.Items);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="index-container">
|
||||
<span className="material-symbols-rounded fill ">play_arrow</span>
|
||||
<Typography className="index">{track.IndexNumber ?? "-"}</Typography>
|
||||
</div>
|
||||
<div className="item-info-track-info">
|
||||
<Typography className="item-info-track-info-name">
|
||||
{track.Name}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
style={{
|
||||
opacity: 0.6,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: "0.6em",
|
||||
}}
|
||||
fontWeight={300}
|
||||
>
|
||||
{track.HasLyrics && <img src={lyricsIcon} alt="lyrics" />}
|
||||
{track.Artists?.join(", ")}
|
||||
</Typography>
|
||||
</div>
|
||||
<Typography>{getRuntimeMusic(track.RunTimeTicks ?? 0)}</Typography>
|
||||
<div className="flex flex-align-center">
|
||||
<LikeButton
|
||||
itemId={track.Id}
|
||||
isFavorite={track.UserData?.IsFavorite}
|
||||
queryKey={["item", "musicTracks"]}
|
||||
userId={user?.Id}
|
||||
itemName={track.Name}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -336,11 +336,6 @@ const PlayButton = ({
|
||||
enqueueSnackbar("No item ID found", { variant: "error" });
|
||||
return;
|
||||
}
|
||||
if (!result?.mediaSource?.MediaSources?.[0]?.Id) {
|
||||
console.error("No media source ID found");
|
||||
enqueueSnackbar("No media source ID found", { variant: "error" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (trackIndex) {
|
||||
// Playlist Playback
|
||||
@@ -363,9 +358,9 @@ const PlayButton = ({
|
||||
navigate({ to: "/player/photos" });
|
||||
}
|
||||
} else {
|
||||
if (!result?.mediaSource) {
|
||||
enqueueSnackbar("No media source found", { variant: "error" });
|
||||
console.error("No media source found");
|
||||
if (!result?.mediaSource?.MediaSources?.[0]?.Id) {
|
||||
console.error("No media source ID found");
|
||||
enqueueSnackbar("No media source ID found", { variant: "error" });
|
||||
return;
|
||||
}
|
||||
const episodeIndex = result.episodeIndex;
|
||||
|
||||
@@ -11,10 +11,10 @@ import {
|
||||
BaseItemKind,
|
||||
type ImageType,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import LikeButton from "../buttons/likeButton";
|
||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||
import PlayButton from "../buttons/playButton";
|
||||
import ErrorBoundary from "../errorBoundary";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
import "./card.scss";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
|
||||
@@ -176,7 +176,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
||||
>
|
||||
{item.PremiereDate && (
|
||||
<Typography style={{ opacity: "0.8" }} variant="subtitle2">
|
||||
{item.ProductionYear ?? ""}
|
||||
{item.ProductionYear}
|
||||
</Typography>
|
||||
)}
|
||||
{item.OfficialRating && (
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import React from "react";
|
||||
class ErrorBoundary extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { hasError: false };
|
||||
}
|
||||
|
||||
static getDerivedStateFromError(error) {
|
||||
// Update state so the next render will show the fallback UI.
|
||||
return { hasError: true };
|
||||
}
|
||||
|
||||
componentDidCatch(error, info) {
|
||||
// Example "componentStack":
|
||||
// in ComponentThatThrows (created by App)
|
||||
// in ErrorBoundary (created by App)
|
||||
// in div (created by App)
|
||||
// in App
|
||||
this.setState;
|
||||
console.error(`Err in ${info} - ${error}`);
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.hasError) {
|
||||
// You can render any custom fallback UI
|
||||
return this.props.fallback;
|
||||
}
|
||||
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
export default ErrorBoundary;
|
||||
@@ -8,6 +8,7 @@
|
||||
height: 16em;
|
||||
box-shadow: $shadow-card-image;
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
&-icon {
|
||||
color: rgb(255 255 255 / 0.5);
|
||||
font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40;
|
||||
|
||||
@@ -1,274 +0,0 @@
|
||||
import React, { useState } from "react";
|
||||
|
||||
import MuiLink from "@mui/material/Link";
|
||||
import Paper from "@mui/material/Paper";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { getRuntimeMusic } from "../../../utils/date/time";
|
||||
|
||||
import { SortOrder } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { useAudioPlayback } from "../../../utils/store/audioPlayback";
|
||||
import LikeButton from "../../buttons/likeButton";
|
||||
import PlayButton from "../../buttons/playButton";
|
||||
|
||||
import TrackList from "../tracksList/index";
|
||||
import "./albumArtist.scss";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { Link, useRouteContext } from "@tanstack/react-router";
|
||||
|
||||
export const ArtistAlbum = ({ user, album, boxProps }) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const albumTracks = useQuery({
|
||||
queryKey: ["artist", "album", album.Id],
|
||||
queryFn: async () => {
|
||||
const result = await getItemsApi(api).getItems({
|
||||
userId: user.Id,
|
||||
parentId: album.Id,
|
||||
sortOrder: SortOrder.Ascending,
|
||||
sortBy: "IndexNumber",
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const [
|
||||
currentTrackItem,
|
||||
setCurrentAudioTrack,
|
||||
setAudioUrl,
|
||||
setAudioDisplay,
|
||||
setAudioItem,
|
||||
setAudioTracks,
|
||||
] = useAudioPlayback((state) => [
|
||||
state.item,
|
||||
state.setCurrentTrack,
|
||||
state.setUrl,
|
||||
state.setDisplay,
|
||||
state.setItem,
|
||||
state.setTracks,
|
||||
]);
|
||||
const playTrack = (index) => {
|
||||
setAudioTracks(albumTracks.data.Items);
|
||||
setCurrentAudioTrack(index);
|
||||
setAudioUrl(
|
||||
`${api.basePath}/Audio/${albumTracks.data.Items[index].Id}/universal?deviceId=${api.deviceInfo.id}&userId=${user.Id}&api_key=${api.accessToken}`,
|
||||
);
|
||||
setAudioItem(albumTracks.data.Items[index]);
|
||||
setAudioDisplay(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ marginBottom: "3em" }} {...boxProps}>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
gap: "1em",
|
||||
marginBottom: "1em",
|
||||
}}
|
||||
>
|
||||
{!!album.ImageTags?.Primary && (
|
||||
<div className="album-image">
|
||||
<img
|
||||
alt={album.Name}
|
||||
src={`${api.basePath}/Items/${album.Id}/Images/Primary?fillHeight=532&fillWidth=532&quality=96`}
|
||||
style={{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
objectFit: "cover",
|
||||
opacity: 0,
|
||||
transition: "opacity 250ms",
|
||||
position: "relative",
|
||||
zIndex: 2,
|
||||
}}
|
||||
onLoad={(e) => (e.currentTarget.style.opacity = 1)}
|
||||
/>
|
||||
<div className="album-image-icon-container">
|
||||
<span
|
||||
className="material-symbols-rounded album-image-icon"
|
||||
style={{ fontSize: "8em" }}
|
||||
>
|
||||
album
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className="flex flex-column"
|
||||
style={{
|
||||
alignItems: "flex-start",
|
||||
justifyContent: "space-between",
|
||||
padding: "1em 0",
|
||||
}}
|
||||
>
|
||||
<div className="flex flex-column">
|
||||
<Typography
|
||||
variant="h4"
|
||||
fontWeight={300}
|
||||
style={{ opacity: "0.6", mb: 1 }}
|
||||
>
|
||||
{album.ProductionYear}
|
||||
</Typography>
|
||||
<MuiLink
|
||||
component={Link}
|
||||
to="/album/$Id"
|
||||
variant="h2"
|
||||
color="inherit"
|
||||
underline="hover"
|
||||
>
|
||||
{album.Name}
|
||||
</MuiLink>
|
||||
</div>
|
||||
<div
|
||||
className=" flex flex-row"
|
||||
style={{
|
||||
gap: "1em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<PlayButton
|
||||
audio
|
||||
itemId={album.Id}
|
||||
itemType={album.Type}
|
||||
itemUserData={album.UserData}
|
||||
userId={user.Id}
|
||||
buttonProps={{
|
||||
color: "white",
|
||||
style: {
|
||||
color: "black ",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
|
||||
<LikeButton
|
||||
itemName={album.Name}
|
||||
key={album.Id}
|
||||
queryKey={[
|
||||
"item",
|
||||
album.ParentBackdropItemId,
|
||||
"artist",
|
||||
"discography",
|
||||
]}
|
||||
isFavorite={album.UserData.IsFavorite}
|
||||
itemId={album.Id}
|
||||
itemType={album.Type}
|
||||
itemUserData={album.UserData}
|
||||
userId={user.Id}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{albumTracks.isSuccess && (
|
||||
<TrackList user={user} tracks={albumTracks.data.Items} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
{
|
||||
/* <div
|
||||
key={0}
|
||||
className="item-detail-album-track"
|
||||
style={{
|
||||
padding: "0.75em 0 ",
|
||||
background: "rgb(0 0 0 / 0.6)",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="h6"
|
||||
fontWeight={400}
|
||||
style={{
|
||||
justifySelf: "end",
|
||||
}}
|
||||
>
|
||||
#
|
||||
</Typography>
|
||||
<div />
|
||||
<Typography
|
||||
variant="h6"
|
||||
style={{
|
||||
justifySelf: "start",
|
||||
}}
|
||||
fontWeight={400}
|
||||
>
|
||||
Name
|
||||
</Typography>
|
||||
<span className="material-symbols-rounded">schedule</span>
|
||||
</div>
|
||||
{/*albumTracks.data.Items.map((track, index) => {
|
||||
return (
|
||||
<div
|
||||
key={track.Id}
|
||||
className={
|
||||
currentTrackItem.Id === track.Id &&
|
||||
currentTrackItem.ParentId === track.ParentId
|
||||
? "item-detail-album-track playing"
|
||||
: "item-detail-album-track"
|
||||
}
|
||||
onClick={() => playTrack(index)}
|
||||
>
|
||||
<Typography
|
||||
variant="subtitle1"
|
||||
style={{
|
||||
justifySelf: "end",
|
||||
}}
|
||||
>
|
||||
{track.IndexNumber ? track.IndexNumber : "-"}
|
||||
</Typography>
|
||||
|
||||
<LikeButton
|
||||
itemId={track.Id}
|
||||
isFavorite={track.UserData?.IsFavorite}
|
||||
queryKey={["artist", "album", album.Id]}
|
||||
userId={user.Id}
|
||||
itemName={track.Name}
|
||||
color={
|
||||
currentTrackItem.Id === track.Id &&
|
||||
currentTrackItem.ParentId === track.ParentId
|
||||
? "hsl(337, 96%, 56%)"
|
||||
: "white"
|
||||
}
|
||||
/>
|
||||
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="subtitle1"
|
||||
style={{
|
||||
justifySelf: "start",
|
||||
}}
|
||||
fontWeight={500}
|
||||
>
|
||||
{track.Name}
|
||||
</Typography>
|
||||
{track.AlbumArtist === "Various Artists" && (
|
||||
<Typography
|
||||
variant="subtitle2"
|
||||
style={{
|
||||
opacity: 0.5,
|
||||
}}
|
||||
>
|
||||
{track.ArtistItems.map((artist) => artist.Name).join(
|
||||
", ",
|
||||
)}
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
<Typography variant="subtitle1">
|
||||
{getRuntimeMusic(track.RunTimeTicks)}
|
||||
</Typography>
|
||||
</div>
|
||||
);
|
||||
})*/
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
import React from "react";
|
||||
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import {
|
||||
type BaseItemDto,
|
||||
SortOrder,
|
||||
type UserDto,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import LikeButton from "../../buttons/likeButton";
|
||||
import PlayButton from "../../buttons/playButton";
|
||||
|
||||
import "./albumArtist.scss";
|
||||
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { Link } from "@tanstack/react-router";
|
||||
|
||||
type ArtistAlbumProps = {
|
||||
user: UserDto;
|
||||
album: BaseItemDto;
|
||||
boxProps?: object;
|
||||
};
|
||||
|
||||
export const ArtistAlbum = ({ user, album, boxProps }: ArtistAlbumProps) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const albumTracks = useQuery({
|
||||
queryKey: ["artist", "album", album.Id],
|
||||
queryFn: async () => {
|
||||
if (!api) return null;
|
||||
const result = await getItemsApi(api).getItems({
|
||||
userId: user.Id,
|
||||
parentId: album.Id,
|
||||
sortOrder: [SortOrder.Ascending],
|
||||
sortBy: ["IndexNumber"],
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
return (
|
||||
<div style={{ marginBottom: "3em" }} {...boxProps}>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
gap: "1em",
|
||||
marginBottom: "1em",
|
||||
}}
|
||||
>
|
||||
{!!album.ImageTags?.Primary && (
|
||||
<div className="album-image">
|
||||
<img
|
||||
alt={album.Name ?? "Album Image"}
|
||||
src={`${api?.basePath}/Items/${album.Id}/Images/Primary?fillHeight=532&fillWidth=532&quality=96`}
|
||||
style={{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
objectFit: "cover",
|
||||
opacity: 0,
|
||||
transition: "opacity 250ms",
|
||||
position: "relative",
|
||||
zIndex: 2,
|
||||
}}
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
/>
|
||||
<div className="album-image-icon-container">
|
||||
<span
|
||||
className="material-symbols-rounded album-image-icon"
|
||||
style={{ fontSize: "8em" }}
|
||||
>
|
||||
album
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className="flex flex-column"
|
||||
style={{
|
||||
alignItems: "flex-start",
|
||||
justifyContent: "space-between",
|
||||
padding: "1em 0",
|
||||
}}
|
||||
>
|
||||
<div className="flex flex-column">
|
||||
<Typography
|
||||
variant="h5"
|
||||
fontWeight={300}
|
||||
style={{ opacity: "0.6" }}
|
||||
>
|
||||
{album.ProductionYear}
|
||||
</Typography>
|
||||
<Link
|
||||
to="/album/$id"
|
||||
params={{ id: album.Id ?? "" }}
|
||||
style={{ color: "white", textDecoration: "none" }}
|
||||
>
|
||||
<Typography variant="h4" color="white">
|
||||
{album.Name}
|
||||
</Typography>
|
||||
</Link>
|
||||
</div>
|
||||
<div
|
||||
className=" flex flex-row"
|
||||
style={{
|
||||
gap: "1em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<PlayButton
|
||||
audio
|
||||
item={album}
|
||||
itemType={album.Type ?? "MusicAlbum"}
|
||||
userId={user.Id}
|
||||
buttonProps={{
|
||||
//@ts-ignore
|
||||
color: "white",
|
||||
style: {
|
||||
color: "black ",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
|
||||
<LikeButton
|
||||
itemName={album.Name}
|
||||
key={album.Id}
|
||||
queryKey={[
|
||||
"item",
|
||||
album.ParentBackdropItemId ?? "",
|
||||
"artist",
|
||||
"discography",
|
||||
]}
|
||||
isFavorite={album.UserData?.IsFavorite}
|
||||
itemId={album.Id}
|
||||
userId={user.Id}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{albumTracks.isSuccess && (albumTracks.data?.Items?.length ?? 0) > 0 && (
|
||||
<div>
|
||||
<div className="item-info-track header">
|
||||
<span className="material-symbols-rounded index">tag</span>
|
||||
<Typography variant="subtitle1">Title</Typography>
|
||||
<Typography variant="subtitle1">Duration</Typography>
|
||||
</div>
|
||||
{albumTracks.data?.Items?.map((track, index) => (
|
||||
<AlbumMusicTrack
|
||||
track={track}
|
||||
trackIndex={index}
|
||||
musicTracks={albumTracks.data}
|
||||
key={track.Id}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -9,7 +9,6 @@ import "./musicTrack.scss";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import type { QueryKey } from "@tanstack/react-query";
|
||||
import lyrics_icon from "../../assets/icons/lyrics.svg";
|
||||
|
||||
/**
|
||||
@@ -37,8 +36,8 @@ const MusicTrack = ({
|
||||
trackIndex,
|
||||
className = "",
|
||||
}: {
|
||||
item?: BaseItemDto | null;
|
||||
queryKey?: QueryKey;
|
||||
item: BaseItemDto;
|
||||
queryKey: string[];
|
||||
userId?: string | undefined;
|
||||
playlistItem?: boolean;
|
||||
playlistItemId?: string;
|
||||
@@ -60,16 +59,21 @@ const MusicTrack = ({
|
||||
</span>
|
||||
</div>
|
||||
<img
|
||||
alt={item.Name}
|
||||
src={getImageUrlsApi(api).getItemImageUrlById(
|
||||
Object.keys(item.ImageTags).length === 0 ? item.AlbumId : item.Id,
|
||||
"Primary",
|
||||
{
|
||||
quality: 70,
|
||||
fillHeight: 128,
|
||||
fillWidth: 128,
|
||||
},
|
||||
)}
|
||||
alt={item.Name ?? "Music Track"}
|
||||
src={
|
||||
api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(
|
||||
(Object.keys(item.ImageTags ?? {}).length === 0
|
||||
? item.AlbumId
|
||||
: item.Id) ?? "",
|
||||
"Primary",
|
||||
{
|
||||
quality: 70,
|
||||
fillHeight: 128,
|
||||
fillWidth: 128,
|
||||
},
|
||||
)
|
||||
}
|
||||
style={{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
@@ -77,14 +81,14 @@ const MusicTrack = ({
|
||||
opacity: 0,
|
||||
}}
|
||||
onLoad={(e) => {
|
||||
e.target.style.opacity = 1;
|
||||
e.currentTarget.style.opacity = "1";
|
||||
}}
|
||||
/>
|
||||
<div className="music-track-image-overlay">
|
||||
<PlayButton
|
||||
itemId={item.Id}
|
||||
item={item}
|
||||
itemType="Audio"
|
||||
userId={userId}
|
||||
itemType={item.Type}
|
||||
size="small"
|
||||
iconOnly
|
||||
audio
|
||||
@@ -119,9 +123,11 @@ const MusicTrack = ({
|
||||
/>
|
||||
)}
|
||||
{item.ArtistItems?.map((artist, index) => (
|
||||
<>
|
||||
<span
|
||||
style={{ display: "inline-flex", alignItems: "center" }}
|
||||
key={artist.Id}
|
||||
>
|
||||
<TextLink
|
||||
key={index}
|
||||
variant={"subtitle2"}
|
||||
location={`/artist/${artist.Id}`}
|
||||
otherProps={{
|
||||
@@ -133,7 +139,7 @@ const MusicTrack = ({
|
||||
>
|
||||
{artist.Name}
|
||||
</TextLink>
|
||||
{index !== item.ArtistItems.length - 1 && (
|
||||
{index !== (item.ArtistItems?.length ?? 0) - 1 && (
|
||||
<span
|
||||
style={{
|
||||
whiteSpace: "pre",
|
||||
@@ -142,12 +148,12 @@ const MusicTrack = ({
|
||||
,{" "}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<Typography variant="subtitl1">
|
||||
{getRuntimeMusic(item.RunTimeTicks)}
|
||||
<Typography variant="subtitle1">
|
||||
{getRuntimeMusic(item.RunTimeTicks ?? 0)}
|
||||
</Typography>
|
||||
<LikeButton
|
||||
itemId={item.Id}
|
||||
|
||||
Reference in new issue
Block a user