Display tracks in item page #26
This commit is contained in:
4 files changed
+531
-218
No files matched your search
@@ -7,6 +7,7 @@ import { CardsSkeleton } from "../skeleton/cards";
|
|||||||
|
|
||||||
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";
|
||||||
|
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
|
||||||
export const LatestMediaSection = ({ latestMediaLib }) => {
|
export const LatestMediaSection = ({ latestMediaLib }) => {
|
||||||
const user = useQuery({
|
const user = useQuery({
|
||||||
@@ -67,7 +68,11 @@ export const LatestMediaSection = ({ latestMediaLib }) => {
|
|||||||
? "sqaure"
|
? "sqaure"
|
||||||
: "portait"
|
: "portait"
|
||||||
}
|
}
|
||||||
watchedStatus={item.UserData.Played}
|
watchedStatus={
|
||||||
|
item.Type == BaseItemKind.Audio
|
||||||
|
? false
|
||||||
|
: item.UserData.Played
|
||||||
|
}
|
||||||
watchedCount={
|
watchedCount={
|
||||||
item.UserData.UnplayedItemCount
|
item.UserData.UnplayedItemCount
|
||||||
}
|
}
|
||||||
|
|||||||
+394
-161
@@ -32,7 +32,11 @@ import { showAppBar, showBackButton } from "../../utils/slice/appBar";
|
|||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { useParams, useNavigate } from "react-router-dom";
|
import { useParams, useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
import {
|
||||||
|
BaseItemKind,
|
||||||
|
ItemFields,
|
||||||
|
MediaStreamType,
|
||||||
|
} 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";
|
||||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
@@ -93,9 +97,6 @@ const ItemDetail = () => {
|
|||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [isMovie, setIsMovie] = useState(false);
|
|
||||||
const [isSeries, setIsSeries] = useState(false);
|
|
||||||
const [isMusicItem, setIsMusicItem] = useState(false);
|
|
||||||
const appBarVisiblity = useSelector((state) => state.appBar.visible);
|
const appBarVisiblity = useSelector((state) => state.appBar.visible);
|
||||||
const [primageImageLoaded, setPrimaryImageLoaded] = useState(false);
|
const [primageImageLoaded, setPrimaryImageLoaded] = useState(false);
|
||||||
const [backdropImageLoaded, setBackdropImageLoaded] = useState(false);
|
const [backdropImageLoaded, setBackdropImageLoaded] = useState(false);
|
||||||
@@ -397,6 +398,45 @@ const ItemDetail = () => {
|
|||||||
personEpisodes.isLoading,
|
personEpisodes.isLoading,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const [videoTracks, setVideoTracks] = useState([]);
|
||||||
|
const [audioTracks, setAudioTracks] = useState([]);
|
||||||
|
const [subtitleTracks, setSubtitleTracks] = useState([]);
|
||||||
|
|
||||||
|
const [currentVideoTrack, setCurrentVideoTrack] = useState();
|
||||||
|
const [currentAudioTrack, setCurrentAudioTrack] = useState();
|
||||||
|
const [currentSubTrack, setCurrentSubTrack] = useState();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (item.isSuccess && !!item.data.MediaStreams) {
|
||||||
|
let videos = [];
|
||||||
|
let audios = [];
|
||||||
|
let subs = [];
|
||||||
|
for (let track of item.data.MediaStreams) {
|
||||||
|
switch (track.Type) {
|
||||||
|
case MediaStreamType.Video:
|
||||||
|
videos.push(track);
|
||||||
|
break;
|
||||||
|
case MediaStreamType.Audio:
|
||||||
|
audios.push(track);
|
||||||
|
break;
|
||||||
|
case MediaStreamType.Subtitle:
|
||||||
|
subs.push(track);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setVideoTracks(videos);
|
||||||
|
setAudioTracks(audios);
|
||||||
|
setSubtitleTracks(subs);
|
||||||
|
|
||||||
|
setCurrentVideoTrack(videos[0].DisplayTitle);
|
||||||
|
setCurrentAudioTrack(audios[0].DisplayTitle);
|
||||||
|
setCurrentSubTrack(subs[0].DisplayTitle);
|
||||||
|
}
|
||||||
|
}, [item.isSuccess]);
|
||||||
|
|
||||||
if (item.isLoading || similarItems.isLoading) {
|
if (item.isLoading || similarItems.isLoading) {
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
@@ -434,6 +474,26 @@ const ItemDetail = () => {
|
|||||||
className="item-detail-image-blurhash"
|
className="item-detail-image-blurhash"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{!!item.data.ParentBackdropImageTags &&
|
||||||
|
item.data.ParentBackdropImageTags.length != 0 && (
|
||||||
|
<Blurhash
|
||||||
|
hash={
|
||||||
|
item.data.ImageBlurHashes.Backdrop[
|
||||||
|
item.data
|
||||||
|
.ParentBackdropImageTags[0]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
resolutionX={14}
|
||||||
|
resolutionY={22}
|
||||||
|
style={{
|
||||||
|
aspectRatio: "0.666",
|
||||||
|
}}
|
||||||
|
punch={1}
|
||||||
|
className="item-detail-image-blurhash"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
recomponent="main"
|
recomponent="main"
|
||||||
@@ -447,7 +507,15 @@ const ItemDetail = () => {
|
|||||||
flexFlow: "column",
|
flexFlow: "column",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box className="item-detail-header" mb={0}>
|
<Box
|
||||||
|
className="item-detail-header"
|
||||||
|
mb={0}
|
||||||
|
paddingTop={
|
||||||
|
item.data.Type == BaseItemKind.MusicAlbum
|
||||||
|
? 10
|
||||||
|
: 0
|
||||||
|
}
|
||||||
|
>
|
||||||
<Box className="item-detail-header-backdrop">
|
<Box className="item-detail-header-backdrop">
|
||||||
{item.data.Type != BaseItemKind.MusicAlbum
|
{item.data.Type != BaseItemKind.MusicAlbum
|
||||||
? item.data.BackdropImageTags.length !=
|
? item.data.BackdropImageTags.length !=
|
||||||
@@ -810,177 +878,342 @@ const ItemDetail = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
{item.data.Genres != 0 && (
|
<TableContainer>
|
||||||
<Box sx={{ mb: 2, width: "50%" }}>
|
<Table>
|
||||||
<Stack
|
<TableBody>
|
||||||
direction="row"
|
{item.data.Genres != 0 && (
|
||||||
gap={1}
|
<TableRow
|
||||||
alignItems="center"
|
sx={{
|
||||||
>
|
"& td, & th": {
|
||||||
<Typography
|
border: 0,
|
||||||
className="item-detail-heading"
|
},
|
||||||
variant="h5"
|
}}
|
||||||
mr={2}
|
>
|
||||||
>
|
<TableCell
|
||||||
Genre
|
sx={{
|
||||||
</Typography>
|
paddingLeft: 0,
|
||||||
{item.data.Genres.map(
|
width: "5%",
|
||||||
(genre, index) => {
|
}}
|
||||||
return (
|
>
|
||||||
<Chip
|
|
||||||
key={index}
|
|
||||||
variant="filled"
|
|
||||||
label={genre}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{item.data.Type == BaseItemKind.MusicAlbum && (
|
|
||||||
<Stack
|
|
||||||
sx={{ mb: 2 }}
|
|
||||||
direction="row"
|
|
||||||
gap={1}
|
|
||||||
alignItems="center"
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
className="item-detail-heading"
|
|
||||||
variant="h5"
|
|
||||||
mr={2}
|
|
||||||
>
|
|
||||||
Artists
|
|
||||||
</Typography>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
gap={0.5}
|
|
||||||
divider={
|
|
||||||
<Typography variant="h6">
|
|
||||||
,
|
|
||||||
</Typography>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{item.data.Artists.map(
|
|
||||||
(mitem, mindex) => {
|
|
||||||
return (
|
|
||||||
<Typography
|
<Typography
|
||||||
key={mindex}
|
className="item-detail-heading"
|
||||||
variant="h6"
|
variant="h5"
|
||||||
|
mr={2}
|
||||||
>
|
>
|
||||||
{mitem}
|
Genre
|
||||||
</Typography>
|
</Typography>
|
||||||
);
|
</TableCell>
|
||||||
},
|
<TableCell>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={1}
|
||||||
|
>
|
||||||
|
{item.data.Genres.map(
|
||||||
|
(
|
||||||
|
genre,
|
||||||
|
index,
|
||||||
|
) => {
|
||||||
|
return (
|
||||||
|
<Chip
|
||||||
|
key={
|
||||||
|
index
|
||||||
|
}
|
||||||
|
variant="filled"
|
||||||
|
label={
|
||||||
|
genre
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!!item.data.MediaStreams &&
|
{item.data.Type ==
|
||||||
item.data.MediaStreams.length != 0 && (
|
BaseItemKind.MusicAlbum && (
|
||||||
<>
|
<TableRow
|
||||||
<Box sx={{ mb: 2, width: "50%" }}>
|
sx={{
|
||||||
<Stack
|
"& td, & th": {
|
||||||
direction="row"
|
border: 0,
|
||||||
gap={1}
|
},
|
||||||
alignItems="center"
|
}}
|
||||||
>
|
>
|
||||||
<Typography
|
<TableCell
|
||||||
className="item-detail-heading"
|
sx={{
|
||||||
variant="h5"
|
paddingLeft: 0,
|
||||||
mr={2}
|
width: "5%",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Video
|
<Typography
|
||||||
</Typography>
|
className="item-detail-heading"
|
||||||
<TextField
|
variant="h5"
|
||||||
defaultValue={
|
mr={2}
|
||||||
item.data
|
>
|
||||||
.MediaStreams[0]
|
Artists
|
||||||
.DisplayTitle
|
</Typography>
|
||||||
}
|
</TableCell>
|
||||||
select
|
<TableCell>
|
||||||
fullWidth
|
<Stack
|
||||||
hiddenLabel
|
direction="row"
|
||||||
>
|
gap={0.5}
|
||||||
{item.data.MediaStreams.map(
|
divider={
|
||||||
(
|
<Typography variant="h6">
|
||||||
stream,
|
,
|
||||||
sindex,
|
</Typography>
|
||||||
) => {
|
}
|
||||||
if (
|
flexWrap="wrap"
|
||||||
stream.Type ==
|
>
|
||||||
BaseItemKind.Video
|
{item.data.Artists.map(
|
||||||
)
|
(
|
||||||
|
mitem,
|
||||||
|
mindex,
|
||||||
|
) => {
|
||||||
return (
|
return (
|
||||||
<MenuItem
|
<Typography
|
||||||
key={
|
key={
|
||||||
sindex
|
mindex
|
||||||
}
|
|
||||||
value={
|
|
||||||
stream.DisplayTitle
|
|
||||||
}
|
}
|
||||||
|
variant="h6"
|
||||||
|
noWrap
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
stream.DisplayTitle
|
mitem
|
||||||
}
|
}
|
||||||
</MenuItem>
|
</Typography>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
)}
|
)}
|
||||||
</TextField>
|
</Stack>
|
||||||
</Stack>
|
</TableCell>
|
||||||
</Box>
|
</TableRow>
|
||||||
<Box sx={{ mb: 2, width: "50%" }}>
|
)}
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
gap={1}
|
|
||||||
alignItems="center"
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
className="item-detail-heading"
|
|
||||||
variant="h5"
|
|
||||||
mr={2}
|
|
||||||
>
|
|
||||||
Audio
|
|
||||||
</Typography>
|
|
||||||
<TextField
|
|
||||||
select
|
|
||||||
fullWidth
|
|
||||||
hiddenLabel
|
|
||||||
>
|
|
||||||
{item.data.MediaStreams.map(
|
|
||||||
(
|
|
||||||
stream,
|
|
||||||
sindex,
|
|
||||||
) => {
|
|
||||||
if (
|
|
||||||
stream.Type ==
|
|
||||||
BaseItemKind.Audio
|
|
||||||
)
|
|
||||||
return (
|
|
||||||
<MenuItem
|
|
||||||
key={
|
|
||||||
sindex
|
|
||||||
}
|
|
||||||
value={
|
|
||||||
stream.DisplayTitle
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{
|
|
||||||
stream.DisplayTitle
|
|
||||||
}
|
|
||||||
</MenuItem>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)}
|
|
||||||
</TextField>
|
|
||||||
</Stack>
|
|
||||||
</Box>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
|
{!!item.data.MediaStreams &&
|
||||||
|
item.data.MediaStreams.length !=
|
||||||
|
0 && (
|
||||||
|
<>
|
||||||
|
{videoTracks != [] && (
|
||||||
|
<TableRow
|
||||||
|
sx={{
|
||||||
|
"& td, & th":
|
||||||
|
{
|
||||||
|
border: 0,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TableCell
|
||||||
|
sx={{
|
||||||
|
paddingLeft: 0,
|
||||||
|
width: "5%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
className="item-detail-heading"
|
||||||
|
variant="h5"
|
||||||
|
mr={
|
||||||
|
2
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Video
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<TextField
|
||||||
|
select
|
||||||
|
sx={{
|
||||||
|
width: "50%",
|
||||||
|
}}
|
||||||
|
hiddenLabel
|
||||||
|
value={
|
||||||
|
currentVideoTrack
|
||||||
|
}
|
||||||
|
onChange={(
|
||||||
|
e,
|
||||||
|
) => {
|
||||||
|
setCurrentVideoTrack(
|
||||||
|
e
|
||||||
|
.target
|
||||||
|
.value,
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{videoTracks.map(
|
||||||
|
(
|
||||||
|
stream,
|
||||||
|
sindex,
|
||||||
|
) => {
|
||||||
|
if (
|
||||||
|
stream.Type ==
|
||||||
|
BaseItemKind.Video
|
||||||
|
)
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
|
key={
|
||||||
|
sindex
|
||||||
|
}
|
||||||
|
value={
|
||||||
|
stream.DisplayTitle
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
stream.DisplayTitle
|
||||||
|
}
|
||||||
|
</MenuItem>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
</TextField>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)}
|
||||||
|
{audioTracks != [] && (
|
||||||
|
<TableRow
|
||||||
|
sx={{
|
||||||
|
"& td, & th":
|
||||||
|
{
|
||||||
|
border: 0,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TableCell
|
||||||
|
sx={{
|
||||||
|
paddingLeft: 0,
|
||||||
|
width: "5%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
className="item-detail-heading"
|
||||||
|
variant="h5"
|
||||||
|
mr={
|
||||||
|
2
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Audio
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<TextField
|
||||||
|
select
|
||||||
|
sx={{
|
||||||
|
width: "50%",
|
||||||
|
}}
|
||||||
|
hiddenLabel
|
||||||
|
value={
|
||||||
|
currentAudioTrack
|
||||||
|
}
|
||||||
|
onChange={(
|
||||||
|
e,
|
||||||
|
) => {
|
||||||
|
setCurrentAudioTrack(
|
||||||
|
e
|
||||||
|
.target
|
||||||
|
.value,
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{audioTracks.map(
|
||||||
|
(
|
||||||
|
stream,
|
||||||
|
sindex,
|
||||||
|
) => {
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
|
key={
|
||||||
|
sindex
|
||||||
|
}
|
||||||
|
value={
|
||||||
|
stream.DisplayTitle
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
stream.DisplayTitle
|
||||||
|
}
|
||||||
|
</MenuItem>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
</TextField>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)}
|
||||||
|
{subtitleTracks !=
|
||||||
|
[] && (
|
||||||
|
<TableRow
|
||||||
|
sx={{
|
||||||
|
"& td, & th":
|
||||||
|
{
|
||||||
|
border: 0,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TableCell
|
||||||
|
sx={{
|
||||||
|
paddingLeft: 0,
|
||||||
|
width: "5%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
className="item-detail-heading"
|
||||||
|
variant="h5"
|
||||||
|
mr={
|
||||||
|
2
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Subtitle
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<TextField
|
||||||
|
select
|
||||||
|
sx={{
|
||||||
|
width: "50%",
|
||||||
|
}}
|
||||||
|
hiddenLabel
|
||||||
|
value={
|
||||||
|
currentSubTrack
|
||||||
|
}
|
||||||
|
onChange={(
|
||||||
|
e,
|
||||||
|
) => {
|
||||||
|
setCurrentSubTrack(
|
||||||
|
e
|
||||||
|
.target
|
||||||
|
.value,
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{subtitleTracks.map(
|
||||||
|
(
|
||||||
|
stream,
|
||||||
|
sindex,
|
||||||
|
) => {
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
|
key={
|
||||||
|
sindex
|
||||||
|
}
|
||||||
|
value={
|
||||||
|
stream.DisplayTitle
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
stream.DisplayTitle
|
||||||
|
}
|
||||||
|
</MenuItem>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
</TextField>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</TableContainer>
|
||||||
{!!item.data.Overview && (
|
{!!item.data.Overview && (
|
||||||
<Box mt={3}>
|
<Box mt={3}>
|
||||||
<Typography variant="h5" mb={1}>
|
<Typography variant="h5" mb={1}>
|
||||||
|
|||||||
+130
-55
@@ -58,6 +58,7 @@ import {
|
|||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
CollectionTypeOptions,
|
CollectionTypeOptions,
|
||||||
ItemFields,
|
ItemFields,
|
||||||
|
SortOrder,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getRuntimeMusic } from "../../utils/date/time";
|
import { getRuntimeMusic } from "../../utils/date/time";
|
||||||
|
|
||||||
@@ -80,27 +81,21 @@ const LibraryView = () => {
|
|||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
|
||||||
const user = useQuery({
|
const user = useQuery({
|
||||||
queryKey: ["libraryView", "user"],
|
queryKey: ["user"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
let usr = await getUserApi(window.api).getCurrentUser();
|
let usr = await getUserApi(window.api).getCurrentUser();
|
||||||
return usr.data;
|
return usr.data;
|
||||||
},
|
},
|
||||||
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
const [sortAscending, setSortAscending] = useState(true);
|
const [sortAscending, setSortAscending] = useState(true);
|
||||||
const [sortBy, setSortBy] = useState("SortName");
|
const [sortBy, setSortBy] = useState();
|
||||||
const [sortByData, setSortByData] = useState([
|
const [sortByData, setSortByData] = useState();
|
||||||
{ title: "Name", value: "SortName" },
|
|
||||||
{ title: "Critic Rating", value: "CriticRating" },
|
|
||||||
{ title: "Rating", value: "CommunityRating" },
|
|
||||||
{ title: "Release Date", value: "PremiereDate" },
|
|
||||||
{ title: "Date Added", value: "DateCreated" },
|
|
||||||
{ title: "Play Count", value: "PlayCount" },
|
|
||||||
{ title: "Runtime", value: "Runtime" },
|
|
||||||
{ title: "Random", value: "Random" },
|
|
||||||
]);
|
|
||||||
const handleSortChange = (e) => {
|
const handleSortChange = (e) => {
|
||||||
setSortAscending(e.target.checked);
|
setSortAscending(e.target.checked);
|
||||||
|
console.log(e.target.checked);
|
||||||
};
|
};
|
||||||
const handleSortBy = (e) => {
|
const handleSortBy = (e) => {
|
||||||
setSortBy(e.target.value);
|
setSortBy(e.target.value);
|
||||||
@@ -118,6 +113,7 @@ const LibraryView = () => {
|
|||||||
queryKey: ["libraryView", "currentLib", id],
|
queryKey: ["libraryView", "currentLib", id],
|
||||||
queryFn: () => fetchLib(id),
|
queryFn: () => fetchLib(id),
|
||||||
enabled: !!user.data,
|
enabled: !!user.data,
|
||||||
|
networkMode: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (currentLib.isSuccess) {
|
if (currentLib.isSuccess) {
|
||||||
@@ -223,8 +219,8 @@ const LibraryView = () => {
|
|||||||
]);
|
]);
|
||||||
} else if (currentLib.data.Items[0].CollectionType == "music") {
|
} else if (currentLib.data.Items[0].CollectionType == "music") {
|
||||||
setViewType([
|
setViewType([
|
||||||
{ title: "Songs", value: BaseItemKind.Audio },
|
|
||||||
{ title: "Albums", value: BaseItemKind.MusicAlbum },
|
{ title: "Albums", value: BaseItemKind.MusicAlbum },
|
||||||
|
{ title: "Songs", value: BaseItemKind.Audio },
|
||||||
{ title: "Artists", value: BaseItemKind.MusicArtist },
|
{ title: "Artists", value: BaseItemKind.MusicArtist },
|
||||||
{ title: "Genres", value: BaseItemKind.MusicGenre },
|
{ title: "Genres", value: BaseItemKind.MusicGenre },
|
||||||
]);
|
]);
|
||||||
@@ -240,9 +236,63 @@ const LibraryView = () => {
|
|||||||
} else {
|
} else {
|
||||||
setViewType([]);
|
setViewType([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentLib.data.Items[0].CollectionType == "movies") {
|
||||||
|
setSortByData([
|
||||||
|
{ title: "Name", value: "SortName" },
|
||||||
|
{ title: "Critic Rating", value: "CriticRating" },
|
||||||
|
{ title: "Rating", value: "CommunityRating" },
|
||||||
|
{ title: "Date Added", value: "DateCreated" },
|
||||||
|
{ title: "Play Count", value: "PlayCount" },
|
||||||
|
{ title: "Release Date", value: "PremiereDate" },
|
||||||
|
{ title: "Runtime", value: "Runtime" },
|
||||||
|
{ title: "Random", value: "Random" },
|
||||||
|
]);
|
||||||
|
} else if (
|
||||||
|
currentLib.data.Items[0].CollectionType == "tvshows"
|
||||||
|
) {
|
||||||
|
setSortByData([
|
||||||
|
{ title: "Name", value: "SortName" },
|
||||||
|
{ title: "Critic Rating", value: "CriticRating" },
|
||||||
|
{ title: "Rating", value: "CommunityRating" },
|
||||||
|
{ title: "Date Added", value: "DateCreated" },
|
||||||
|
{ title: "Date Played", value: "DatePlayed" },
|
||||||
|
{ title: "Release Date", value: "PremiereDate" },
|
||||||
|
{ title: "Random", value: "Random" },
|
||||||
|
]);
|
||||||
|
} else if (currentLib.data.Items[0].CollectionType == "music") {
|
||||||
|
setSortByData([
|
||||||
|
{ title: "Name", value: "Name" },
|
||||||
|
{ title: "Album Artist", value: "AlbumArtist" },
|
||||||
|
{ title: "Critic Rating", value: "CriticRating" },
|
||||||
|
{ title: "Rating", value: "CommunityRating" },
|
||||||
|
{ title: "Release Date", value: "PremiereDate" },
|
||||||
|
{ title: "Date Added", value: "DateCreated" },
|
||||||
|
{ title: "Play Count", value: "PlayCount" },
|
||||||
|
{ title: "Runtime", value: "Runtime" },
|
||||||
|
{ title: "Random", value: "Random" },
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
setSortByData([
|
||||||
|
{ title: "Name", value: "SortName" },
|
||||||
|
{ title: "Critic Rating", value: "CriticRating" },
|
||||||
|
{ title: "Rating", value: "CommunityRating" },
|
||||||
|
{ title: "Release Date", value: "PremiereDate" },
|
||||||
|
{ title: "Date Added", value: "DateCreated" },
|
||||||
|
{ title: "Play Count", value: "PlayCount" },
|
||||||
|
{ title: "Runtime", value: "Runtime" },
|
||||||
|
{ title: "Random", value: "Random" },
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [currentLib.isSuccess]);
|
}, [currentLib.isSuccess]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (sortByData != undefined) {
|
||||||
|
setSortBy(sortByData[0].value);
|
||||||
|
}
|
||||||
|
}, [sortByData]);
|
||||||
|
|
||||||
const fetchLibItems = async (libraryId) => {
|
const fetchLibItems = async (libraryId) => {
|
||||||
let result;
|
let result;
|
||||||
if (currentViewType == "MusicArtist") {
|
if (currentViewType == "MusicArtist") {
|
||||||
@@ -284,7 +334,11 @@ const LibraryView = () => {
|
|||||||
? undefined
|
? undefined
|
||||||
: true,
|
: true,
|
||||||
includeItemTypes: [currentViewType],
|
includeItemTypes: [currentViewType],
|
||||||
sortOrder: [sortAscending ? "Ascending" : "Descending"],
|
sortOrder: [
|
||||||
|
sortAscending
|
||||||
|
? SortOrder.Ascending
|
||||||
|
: SortOrder.Descending,
|
||||||
|
],
|
||||||
sortBy: sortBy,
|
sortBy: sortBy,
|
||||||
filters: [
|
filters: [
|
||||||
isPlayed && "IsPlayed",
|
isPlayed && "IsPlayed",
|
||||||
@@ -318,7 +372,9 @@ const LibraryView = () => {
|
|||||||
`page: ${page}`,
|
`page: ${page}`,
|
||||||
[
|
[
|
||||||
currentViewType,
|
currentViewType,
|
||||||
sortAscending,
|
|
||||||
|
sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
||||||
|
,
|
||||||
sortBy,
|
sortBy,
|
||||||
[
|
[
|
||||||
isPlayed,
|
isPlayed,
|
||||||
@@ -753,52 +809,68 @@ const LibraryView = () => {
|
|||||||
currentViewType,
|
currentViewType,
|
||||||
) && (
|
) && (
|
||||||
<>
|
<>
|
||||||
<Checkbox
|
{sortByData != undefined && (
|
||||||
icon={<MdiSortDescending />}
|
<>
|
||||||
checkedIcon={
|
<Checkbox
|
||||||
<MdiSortAscending />
|
icon={
|
||||||
}
|
<MdiSortDescending />
|
||||||
sx={{
|
}
|
||||||
color: "white !important",
|
checkedIcon={
|
||||||
}}
|
<MdiSortAscending />
|
||||||
color="white"
|
}
|
||||||
onChange={handleSortChange}
|
sx={{
|
||||||
defaultValue={sortAscending}
|
color: "white !important",
|
||||||
/>
|
}}
|
||||||
<TextField
|
color="white"
|
||||||
select
|
onChange={
|
||||||
hiddenLabel
|
handleSortChange
|
||||||
defaultValue={
|
}
|
||||||
sortByData[0].value
|
checked={
|
||||||
}
|
sortAscending
|
||||||
size="small"
|
}
|
||||||
variant="filled"
|
/>
|
||||||
onChange={handleSortBy}
|
<TextField
|
||||||
>
|
select
|
||||||
{sortByData.map(
|
hiddenLabel
|
||||||
(item, index) => {
|
value={
|
||||||
return (
|
sortByData[0]
|
||||||
<MenuItem
|
.value
|
||||||
key={
|
}
|
||||||
item.value
|
size="small"
|
||||||
}
|
variant="filled"
|
||||||
value={
|
onChange={
|
||||||
item.value
|
handleSortBy
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{`By ${item.title}`}
|
{sortByData.map(
|
||||||
</MenuItem>
|
(
|
||||||
);
|
item,
|
||||||
},
|
index,
|
||||||
)}
|
) => {
|
||||||
</TextField>
|
return (
|
||||||
|
<MenuItem
|
||||||
|
key={
|
||||||
|
index
|
||||||
|
}
|
||||||
|
value={
|
||||||
|
item.value
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{`By ${item.title}`}
|
||||||
|
</MenuItem>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
</TextField>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{viewType.length != 0 && (
|
{viewType.length != 0 && (
|
||||||
<TextField
|
<TextField
|
||||||
select
|
select
|
||||||
hiddenLabel
|
hiddenLabel
|
||||||
defaultValue={viewType[0].value}
|
value={viewType[0].value}
|
||||||
size="small"
|
size="small"
|
||||||
variant="filled"
|
variant="filled"
|
||||||
onChange={handleCurrentViewType}
|
onChange={handleCurrentViewType}
|
||||||
@@ -979,6 +1051,9 @@ const LibraryView = () => {
|
|||||||
sx={{
|
sx={{
|
||||||
opacity: 0.7,
|
opacity: 0.7,
|
||||||
}}
|
}}
|
||||||
|
key={
|
||||||
|
aindex
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
artist
|
artist
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export const getRuntimeFull = (ticks) => {
|
|||||||
timeMin -= timeHr * 60;
|
timeMin -= timeHr * 60;
|
||||||
formatedTime = `${timeHr} hour ${timeMin} minutes`;
|
formatedTime = `${timeHr} hour ${timeMin} minutes`;
|
||||||
} else {
|
} else {
|
||||||
formatedTime = `${timeMin} minutes ${timeSec} seconds`;
|
formatedTime = `${timeMin} minutes`;
|
||||||
}
|
}
|
||||||
return formatedTime;
|
return formatedTime;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user