refactor: change GenreView to genreFilter
This commit is contained in:
8 files changed
+173
-336
No files matched your search
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
|
|
||||||
"build": {
|
"build": {
|
||||||
"beforeBuildCommand": "pnpm run build",
|
"beforeBuildCommand": "pnpm run build",
|
||||||
"beforeDevCommand": "pnpm run dev",
|
"beforeDevCommand": "pnpm run dev",
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ const PlayButton = ({
|
|||||||
// Subtitle
|
// Subtitle
|
||||||
const subtitle = getSubtitle(
|
const subtitle = getSubtitle(
|
||||||
currentSubTrack,
|
currentSubTrack,
|
||||||
result?.mediaSource?.MediaSources?.[0].MediaStreams,
|
result?.mediaSource?.MediaSources?.[0]?.MediaStreams,
|
||||||
);
|
);
|
||||||
// URL generation
|
// URL generation
|
||||||
const urlOptions: URLSearchParams = {
|
const urlOptions: URLSearchParams = {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
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";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,8 +21,9 @@ export const LatestMediaSection = ({
|
|||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
const fetchLatestMedia = async (library: BaseItemDto) => {
|
const fetchLatestMedia = async (library: BaseItemDto) => {
|
||||||
|
if (!api || !user?.Id) return null;
|
||||||
const media = await getUserLibraryApi(api).getLatestMedia({
|
const media = await getUserLibraryApi(api).getLatestMedia({
|
||||||
userId: user?.Id,
|
userId: user.Id,
|
||||||
parentId: library.Id,
|
parentId: library.Id,
|
||||||
limit: 16,
|
limit: 16,
|
||||||
fields: ["PrimaryImageAspectRatio", "ParentId"],
|
fields: ["PrimaryImageAspectRatio", "ParentId"],
|
||||||
@@ -39,10 +39,10 @@ export const LatestMediaSection = ({
|
|||||||
if (data.isPending) {
|
if (data.isPending) {
|
||||||
return <CardsSkeleton />;
|
return <CardsSkeleton />;
|
||||||
}
|
}
|
||||||
if (data.isSuccess && data.data.length >= 1) {
|
if (data.isSuccess && (data.data?.length ?? 0) >= 1) {
|
||||||
return (
|
return (
|
||||||
<CardScroller displayCards={7} title={`Latest ${latestMediaLib.Name}`}>
|
<CardScroller displayCards={7} title={`Latest ${latestMediaLib.Name}`}>
|
||||||
{data.data.map((item) => {
|
{data.data?.map((item) => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
@@ -73,14 +73,8 @@ export const LatestMediaSection = ({
|
|||||||
? "square"
|
? "square"
|
||||||
: "portrait"
|
: "portrait"
|
||||||
}
|
}
|
||||||
queryKey={["home", "latestMedia", latestMediaLib.Id]}
|
queryKey={["home", "latestMedia", latestMediaLib.Id ?? ""]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
import React from "react";
|
|
||||||
import { Card } from "../../../card/card";
|
|
||||||
import cardScroller from "../../../cardScroller/cardScroller";
|
|
||||||
|
|
||||||
const GenreView = ({ libraryId, genreId, genreName, userId }) => {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
|
|
||||||
const items = useQuery({
|
|
||||||
queryKey: ["library", "genreItem", genreId],
|
|
||||||
queryFn: async () => {
|
|
||||||
const result = await getItemsApi(api).getItems({
|
|
||||||
genreIds: [genreId],
|
|
||||||
parentId: libraryId,
|
|
||||||
userId: userId,
|
|
||||||
});
|
|
||||||
return result.data;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (items.isSuccess && items.data.Items.length > 0) {
|
|
||||||
return (
|
|
||||||
<div className="library-genre">
|
|
||||||
<cardScroller.CardScroller
|
|
||||||
title={genreName}
|
|
||||||
displayCards={8}
|
|
||||||
disableDecoration
|
|
||||||
>
|
|
||||||
{items.data.Items.map((item) => {
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
key={item.Id}
|
|
||||||
item={item}
|
|
||||||
seriesId={item.SeriesId}
|
|
||||||
cardTitle={
|
|
||||||
item.Type === BaseItemKind.Episode
|
|
||||||
? item.SeriesName
|
|
||||||
: item.Name
|
|
||||||
}
|
|
||||||
imageType={"Primary"}
|
|
||||||
cardCaption={
|
|
||||||
item.Type === BaseItemKind.Episode
|
|
||||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
|
||||||
: item.Type === BaseItemKind.Series
|
|
||||||
? `${item.ProductionYear} - ${
|
|
||||||
item.EndDate
|
|
||||||
? new Date(item.EndDate).toLocaleString([], {
|
|
||||||
year: "numeric",
|
|
||||||
})
|
|
||||||
: "Present"
|
|
||||||
}`
|
|
||||||
: item.ProductionYear
|
|
||||||
}
|
|
||||||
disableOverlay={
|
|
||||||
item.Type === BaseItemKind.Person ||
|
|
||||||
item.Type === BaseItemKind.MusicAlbum ||
|
|
||||||
item.Type === BaseItemKind.Genre ||
|
|
||||||
item.Type === BaseItemKind.MusicGenre ||
|
|
||||||
item.Type === BaseItemKind.Studio
|
|
||||||
}
|
|
||||||
cardType={
|
|
||||||
item.Type === BaseItemKind.MusicAlbum ||
|
|
||||||
item.Type === BaseItemKind.Audio ||
|
|
||||||
item.Type === BaseItemKind.Genre ||
|
|
||||||
item.Type === BaseItemKind.MusicGenre ||
|
|
||||||
item.Type === BaseItemKind.Studio ||
|
|
||||||
item.Type === BaseItemKind.Playlist
|
|
||||||
? "square"
|
|
||||||
: "portrait"
|
|
||||||
}
|
|
||||||
queryKey={["library", "genreItem", genreId]}
|
|
||||||
userId={userId}
|
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</cardScroller.CardScroller>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default GenreView;
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
// Types
|
|
||||||
import type { BaseItemDto, UserDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
|
|
||||||
import { getRuntimeMusic } from "../../../utils/date/time";
|
|
||||||
import { useAudioPlayback } from "../../../utils/store/audioPlayback";
|
|
||||||
import LikeButton from "../../buttons/likeButton";
|
|
||||||
import "./tracksList.scss";
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
export default function TracksList({
|
|
||||||
tracks,
|
|
||||||
user,
|
|
||||||
queryKey,
|
|
||||||
}: { tracks: BaseItemDto[]; user: UserDto; queryKey: [] }) {
|
|
||||||
const api = useApiInContext((s) => s.api);
|
|
||||||
|
|
||||||
const [
|
|
||||||
currentItem,
|
|
||||||
setCurrentAudioTrack,
|
|
||||||
setAudioUrl,
|
|
||||||
setAudioDisplay,
|
|
||||||
setAudioItem,
|
|
||||||
setAudioTracks,
|
|
||||||
] = useAudioPlayback((state) => [
|
|
||||||
state.item,
|
|
||||||
state.setCurrentTrack,
|
|
||||||
state.setUrl,
|
|
||||||
state.setDisplay,
|
|
||||||
state.setItem,
|
|
||||||
state.setTracks,
|
|
||||||
]);
|
|
||||||
const playTrack = (index: number) => {
|
|
||||||
setAudioTracks(tracks);
|
|
||||||
setCurrentAudioTrack(index);
|
|
||||||
setAudioUrl(
|
|
||||||
`${api.basePath}/Audio/${tracks[index].Id}/universal?deviceId=${api.deviceInfo.id}&userId=${user.Id}&api_key=${api.accessToken}`,
|
|
||||||
);
|
|
||||||
setAudioItem(tracks[index]);
|
|
||||||
setAudioDisplay(true);
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div className="track-list">
|
|
||||||
<div className="track track-header">
|
|
||||||
<Typography variant="h6">#</Typography>
|
|
||||||
<div>{""}</div>
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Name
|
|
||||||
</Typography>
|
|
||||||
<span className="material-symbols-rounded">schedule</span>
|
|
||||||
</div>
|
|
||||||
{tracks.map((track, index) => (
|
|
||||||
<div
|
|
||||||
className={currentItem?.Id === track.Id ? "track playing" : "track"}
|
|
||||||
key={track.Id}
|
|
||||||
onClick={() => playTrack(index)}
|
|
||||||
>
|
|
||||||
{currentItem?.Id === track.Id ? (
|
|
||||||
<span className="material-symbols-rounded ">equalizer</span>
|
|
||||||
) : (
|
|
||||||
<Typography>{track.IndexNumber ?? "-"}</Typography>
|
|
||||||
)}
|
|
||||||
<LikeButton
|
|
||||||
itemId={track.Id}
|
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
|
||||||
queryKey={queryKey}
|
|
||||||
userId={user.Id}
|
|
||||||
itemName={track.Name}
|
|
||||||
/>
|
|
||||||
<Typography
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{track.Name}
|
|
||||||
</Typography>
|
|
||||||
<Typography>{getRuntimeMusic(track?.RunTimeTicks)}</Typography>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
.track{
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 4% 1fr 80% 1fr;
|
|
||||||
align-items: center;
|
|
||||||
justify-items: center;
|
|
||||||
gap: 0.5em;
|
|
||||||
width: 100%;
|
|
||||||
transition: background $transition-time-default;
|
|
||||||
padding: 0.4em;
|
|
||||||
border-bottom: 1px solid rgb(255 255 255 / 0.1);
|
|
||||||
cursor: pointer;
|
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
&:hover{
|
|
||||||
background: rgb(255 255 255 / 0.1);
|
|
||||||
}
|
|
||||||
&.playing {
|
|
||||||
background: rgb(255 255 255 / 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
&-list {
|
|
||||||
background: rgb(0 0 0 / 0.4);
|
|
||||||
backdrop-filter: blur(5px);
|
|
||||||
border-radius: 20px;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 1px solid rgb(255 255 255 / 0.2);
|
|
||||||
margin-bottom: 2em;
|
|
||||||
}
|
|
||||||
&-header{
|
|
||||||
background: rgb(0 0 0 / 0.4) !important;
|
|
||||||
padding: 0.8em 0.4em;
|
|
||||||
}
|
|
||||||
> *:first-child {
|
|
||||||
justify-self: end;
|
|
||||||
}
|
|
||||||
&:last-child {
|
|
||||||
border-bottom: 0px solid !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,22 +11,9 @@ import { useApiInContext } from "@/utils/store/api";
|
|||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import lyrics_icon from "../../assets/icons/lyrics.svg";
|
import lyrics_icon from "../../assets/icons/lyrics.svg";
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Props
|
|
||||||
* @property {import("@jellyfin/sdk/lib/generated-client/models").BaseItemDto} item
|
|
||||||
* @property {Array} queryKey
|
|
||||||
* @property {string} userId
|
|
||||||
* @property {bool} playlistItem
|
|
||||||
* @property {number} trackIndex
|
|
||||||
* @property {string | undefined} playlistItemId
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Music Track element displayed in ArtistTitlePage and Songs library
|
* @description Music Track element displayed in ArtistTitlePage and Songs library
|
||||||
* @param {Props}
|
|
||||||
* @returns {React.Component}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const MusicTrack = ({
|
const MusicTrack = ({
|
||||||
item,
|
item,
|
||||||
queryKey,
|
queryKey,
|
||||||
|
|||||||
+167
-89
@@ -28,11 +28,11 @@ import { getMusicGenresApi } from "@jellyfin/sdk/lib/utils/api/music-genres-api"
|
|||||||
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
||||||
import { getStudiosApi } from "@jellyfin/sdk/lib/utils/api/studios-api";
|
import { getStudiosApi } from "@jellyfin/sdk/lib/utils/api/studios-api";
|
||||||
|
|
||||||
import GenreView from "@/components/layouts/library/genreView";
|
|
||||||
import MusicTrack from "@/components/musicTrack";
|
import MusicTrack from "@/components/musicTrack";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
import {
|
import {
|
||||||
|
type BaseItemDto,
|
||||||
type BaseItemDtoQueryResult,
|
type BaseItemDtoQueryResult,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
CollectionType,
|
CollectionType,
|
||||||
@@ -43,13 +43,7 @@ import {
|
|||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
|
||||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||||
import {
|
import { FormControl, Menu, Stack, useScrollTrigger } from "@mui/material";
|
||||||
FormControl,
|
|
||||||
Menu,
|
|
||||||
Select,
|
|
||||||
Stack,
|
|
||||||
useScrollTrigger,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { useWindowVirtualizer } from "@tanstack/react-virtual";
|
import { useWindowVirtualizer } from "@tanstack/react-virtual";
|
||||||
import type { AxiosResponse } from "axios";
|
import type { AxiosResponse } from "axios";
|
||||||
import "./library.scss";
|
import "./library.scss";
|
||||||
@@ -83,10 +77,10 @@ const useWindowWidth = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/library/$id")({
|
export const Route = createFileRoute("/_api/library/$id")({
|
||||||
component: LibraryView,
|
component: Library,
|
||||||
});
|
});
|
||||||
|
|
||||||
function LibraryView() {
|
function Library() {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
|
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
@@ -94,8 +88,9 @@ function LibraryView() {
|
|||||||
const user = useCentralStore((s) => s.currentUser);
|
const user = useCentralStore((s) => s.currentUser);
|
||||||
|
|
||||||
const currentLib = useQuery({
|
const currentLib = useQuery({
|
||||||
queryKey: ["libraryView", "currentLib", id],
|
queryKey: ["library", "currentLib", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getUserLibraryApi(api).getItem({
|
const result = await getUserLibraryApi(api).getItem({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
@@ -107,9 +102,58 @@ function LibraryView() {
|
|||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [currentViewType, setCurrentViewType] = useState<BaseItemKind | "Artist">(
|
const genres = useQuery({
|
||||||
undefined!,
|
queryKey: ["library", "genreItem", id],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
|
if (currentLib.data?.CollectionType === "music") {
|
||||||
|
const result = await getMusicGenresApi(api).getMusicGenres({
|
||||||
|
parentId: id,
|
||||||
|
userId: user?.Id,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
}
|
||||||
|
const result = await getGenresApi(api).getGenres({
|
||||||
|
parentId: id,
|
||||||
|
userId: user?.Id,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [genreFilter, setGenreFilter] = useState<string[]>(() => {
|
||||||
|
const cachedVal = sessionStorage.getItem(
|
||||||
|
`library-${currentLib.data?.Id}-config_genreFilter`,
|
||||||
);
|
);
|
||||||
|
if (cachedVal) {
|
||||||
|
return JSON.parse(cachedVal);
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
const handleGenreFilter = useCallback(
|
||||||
|
(e: ChangeEvent<HTMLInputElement>, genre: BaseItemDto) => {
|
||||||
|
if (e.target.checked) {
|
||||||
|
const genreFilterTemp = [...genreFilter, genre.Id];
|
||||||
|
setGenreFilter((s) => (genre.Id ? [...s, genre.Id] : s));
|
||||||
|
sessionStorage.setItem(
|
||||||
|
`library-${currentLib.data?.Id}-config_genreFilter`,
|
||||||
|
JSON.stringify(genreFilterTemp),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const genreFilterTemp = genreFilter.filter((id) => id !== genre.Id);
|
||||||
|
setGenreFilter((s) => s.filter((id) => id !== genre.Id));
|
||||||
|
sessionStorage.setItem(
|
||||||
|
`library-${currentLib.data?.Id}-config_genreFilter`,
|
||||||
|
JSON.stringify(genreFilterTemp),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[genres.data?.Items?.length, id],
|
||||||
|
);
|
||||||
|
|
||||||
|
const [currentViewType, setCurrentViewType] = useState<
|
||||||
|
BaseItemKind | "Artist"
|
||||||
|
>(undefined!);
|
||||||
const availableViewTypes: ViewObject[] = useMemo(() => {
|
const availableViewTypes: ViewObject[] = useMemo(() => {
|
||||||
let result: ViewObject[] = undefined!;
|
let result: ViewObject[] = undefined!;
|
||||||
switch (currentLib.data?.CollectionType) {
|
switch (currentLib.data?.CollectionType) {
|
||||||
@@ -486,7 +530,7 @@ function LibraryView() {
|
|||||||
|
|
||||||
const items = useQuery({
|
const items = useQuery({
|
||||||
queryKey: [
|
queryKey: [
|
||||||
"libraryView",
|
"library",
|
||||||
"currentLibItems",
|
"currentLibItems",
|
||||||
id,
|
id,
|
||||||
{
|
{
|
||||||
@@ -495,9 +539,11 @@ function LibraryView() {
|
|||||||
sortBy: sortBy,
|
sortBy: sortBy,
|
||||||
filters,
|
filters,
|
||||||
videoTypesState,
|
videoTypesState,
|
||||||
|
genreFilter,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
let result: AxiosResponse<BaseItemDtoQueryResult, any>;
|
let result: AxiosResponse<BaseItemDtoQueryResult, any>;
|
||||||
if (currentViewType === "MusicArtist") {
|
if (currentViewType === "MusicArtist") {
|
||||||
result = await getArtistsApi(api).getAlbumArtists({
|
result = await getArtistsApi(api).getAlbumArtists({
|
||||||
@@ -514,16 +560,6 @@ function LibraryView() {
|
|||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
personTypes: ["Actor"],
|
personTypes: ["Actor"],
|
||||||
});
|
});
|
||||||
} else if (currentViewType === "Genre") {
|
|
||||||
result = await getGenresApi(api).getGenres({
|
|
||||||
userId: user?.Id,
|
|
||||||
parentId: id,
|
|
||||||
});
|
|
||||||
} else if (currentViewType === "MusicGenre") {
|
|
||||||
result = await getMusicGenresApi(api).getMusicGenres({
|
|
||||||
userId: user?.Id,
|
|
||||||
parentId: id,
|
|
||||||
});
|
|
||||||
} else if (currentViewType === "Studio") {
|
} else if (currentViewType === "Studio") {
|
||||||
result = await getStudiosApi(api).getStudios({
|
result = await getStudiosApi(api).getStudios({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
@@ -563,6 +599,7 @@ function LibraryView() {
|
|||||||
is4K: filters.is4K || undefined,
|
is4K: filters.is4K || undefined,
|
||||||
is3D: filters.is3D || undefined,
|
is3D: filters.is3D || undefined,
|
||||||
enableUserData: true,
|
enableUserData: true,
|
||||||
|
genreIds: genreFilter,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const videoTypes: VideoType[] = [];
|
const videoTypes: VideoType[] = [];
|
||||||
@@ -598,14 +635,13 @@ function LibraryView() {
|
|||||||
is4K: filters.is4K || undefined,
|
is4K: filters.is4K || undefined,
|
||||||
is3D: filters.is3D || undefined,
|
is3D: filters.is3D || undefined,
|
||||||
enableUserData: true,
|
enableUserData: true,
|
||||||
|
genreIds: genreFilter,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
// enabled: false,
|
|
||||||
enabled: !!user?.Id && Boolean(currentViewType) && currentLib.isSuccess,
|
enabled: !!user?.Id && Boolean(currentViewType) && currentLib.isSuccess,
|
||||||
networkMode: "always",
|
networkMode: "always",
|
||||||
// gcTime: 0,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const disableSort = useMemo(() => {
|
const disableSort = useMemo(() => {
|
||||||
@@ -646,7 +682,7 @@ function LibraryView() {
|
|||||||
? 260
|
? 260
|
||||||
: 356,
|
: 356,
|
||||||
[items.dataUpdatedAt],
|
[items.dataUpdatedAt],
|
||||||
); // This sets the approx height of each card in libraryView to estimate no of virtual rows to render
|
); // This sets the approx height of each card in library to estimate no of virtual rows to render
|
||||||
const windowWidth = useWindowWidth();
|
const windowWidth = useWindowWidth();
|
||||||
const itemsPerRow = useMemo(
|
const itemsPerRow = useMemo(
|
||||||
() => Math.max(1, Math.floor(windowWidth / 200)),
|
() => Math.max(1, Math.floor(windowWidth / 200)),
|
||||||
@@ -694,10 +730,10 @@ function LibraryView() {
|
|||||||
|
|
||||||
const backdropItems = useMemo(() => {
|
const backdropItems = useMemo(() => {
|
||||||
if (items.isSuccess) {
|
if (items.isSuccess) {
|
||||||
const temp = items.data.Items?.filter(
|
const temp = items.data?.Items?.filter(
|
||||||
(item) => item.BackdropImageTags?.length,
|
(item) => item.BackdropImageTags?.length,
|
||||||
);
|
);
|
||||||
if (temp?.[0]?.Id) {
|
if (temp?.[0]?.Id && api) {
|
||||||
setBackdrop(
|
setBackdrop(
|
||||||
getImageUrlsApi(api).getItemImageUrlById(temp?.[0]?.Id, "Backdrop", {
|
getImageUrlsApi(api).getItemImageUrlById(temp?.[0]?.Id, "Backdrop", {
|
||||||
tag: temp?.[0]?.BackdropImageTags?.[0],
|
tag: temp?.[0]?.BackdropImageTags?.[0],
|
||||||
@@ -710,7 +746,7 @@ function LibraryView() {
|
|||||||
}, [items]);
|
}, [items]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (backdropItems?.length) {
|
if (backdropItems?.length && api) {
|
||||||
const intervalId = setInterval(() => {
|
const intervalId = setInterval(() => {
|
||||||
const itemIndex = Math.floor(Math.random() * backdropItems?.length);
|
const itemIndex = Math.floor(Math.random() * backdropItems?.length);
|
||||||
const backdropItem = backdropItems[itemIndex];
|
const backdropItem = backdropItems[itemIndex];
|
||||||
@@ -730,8 +766,6 @@ function LibraryView() {
|
|||||||
}
|
}
|
||||||
}, [backdropItems]);
|
}, [backdropItems]);
|
||||||
|
|
||||||
const [test, setTest] = useState(1);
|
|
||||||
|
|
||||||
if (items.isError) {
|
if (items.isError) {
|
||||||
console.error(items.error);
|
console.error(items.error);
|
||||||
}
|
}
|
||||||
@@ -778,7 +812,7 @@ function LibraryView() {
|
|||||||
{currentLib.isPending ? (
|
{currentLib.isPending ? (
|
||||||
<CircularProgress sx={{ p: 1 }} />
|
<CircularProgress sx={{ p: 1 }} />
|
||||||
) : (
|
) : (
|
||||||
currentLib.data.Name
|
currentLib.data?.Name
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Chip
|
<Chip
|
||||||
@@ -786,7 +820,7 @@ function LibraryView() {
|
|||||||
!items.isSuccess ? (
|
!items.isSuccess ? (
|
||||||
<CircularProgress sx={{ p: 1.5 }} />
|
<CircularProgress sx={{ p: 1.5 }} />
|
||||||
) : (
|
) : (
|
||||||
items.data.TotalRecordCount
|
items.data?.TotalRecordCount
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -880,7 +914,7 @@ function LibraryView() {
|
|||||||
</TextField>
|
</TextField>
|
||||||
)}
|
)}
|
||||||
{!disableFilters && (
|
{!disableFilters && (
|
||||||
<>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
startIcon={
|
startIcon={
|
||||||
<span className="material-symbols-rounded">
|
<span className="material-symbols-rounded">
|
||||||
@@ -907,6 +941,8 @@ function LibraryView() {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{currentViewType !== "Audio" && (
|
||||||
|
<div>
|
||||||
<Typography
|
<Typography
|
||||||
variant="h6"
|
variant="h6"
|
||||||
fontWeight={600}
|
fontWeight={600}
|
||||||
@@ -927,7 +963,9 @@ function LibraryView() {
|
|||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={filters.isPlayed}
|
checked={filters.isPlayed}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) =>
|
||||||
setFilters((s) => ({
|
setFilters((s) => ({
|
||||||
...s,
|
...s,
|
||||||
isPlayed: e.target.checked,
|
isPlayed: e.target.checked,
|
||||||
@@ -941,7 +979,9 @@ function LibraryView() {
|
|||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={filters.isUnPlayed}
|
checked={filters.isUnPlayed}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) =>
|
||||||
setFilters((s) => ({
|
setFilters((s) => ({
|
||||||
...s,
|
...s,
|
||||||
isUnPlayed: e.target.checked,
|
isUnPlayed: e.target.checked,
|
||||||
@@ -955,7 +995,9 @@ function LibraryView() {
|
|||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={filters.isResumable}
|
checked={filters.isResumable}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) =>
|
||||||
setFilters((s) => ({
|
setFilters((s) => ({
|
||||||
...s,
|
...s,
|
||||||
isResumable: e.target.checked,
|
isResumable: e.target.checked,
|
||||||
@@ -969,7 +1011,9 @@ function LibraryView() {
|
|||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={filters.isFavorite}
|
checked={filters.isFavorite}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) =>
|
||||||
setFilters((s) => ({
|
setFilters((s) => ({
|
||||||
...s,
|
...s,
|
||||||
isFavorite: e.target.checked,
|
isFavorite: e.target.checked,
|
||||||
@@ -980,6 +1024,10 @@ function LibraryView() {
|
|||||||
label="Favorites"
|
label="Favorites"
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{currentViewType !== "Audio" && (
|
||||||
|
<div>
|
||||||
<Typography
|
<Typography
|
||||||
variant="h6"
|
variant="h6"
|
||||||
fontWeight={600}
|
fontWeight={600}
|
||||||
@@ -1000,7 +1048,9 @@ function LibraryView() {
|
|||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={filters.hasSubtitles}
|
checked={filters.hasSubtitles}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) =>
|
||||||
setFilters((s) => ({
|
setFilters((s) => ({
|
||||||
...s,
|
...s,
|
||||||
hasSubtitles: e.target.checked,
|
hasSubtitles: e.target.checked,
|
||||||
@@ -1014,7 +1064,9 @@ function LibraryView() {
|
|||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={filters.hasTrailer}
|
checked={filters.hasTrailer}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) =>
|
||||||
setFilters((s) => ({
|
setFilters((s) => ({
|
||||||
...s,
|
...s,
|
||||||
hasTrailer: e.target.checked,
|
hasTrailer: e.target.checked,
|
||||||
@@ -1028,7 +1080,9 @@ function LibraryView() {
|
|||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={filters.hasSpecialFeature}
|
checked={filters.hasSpecialFeature}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) =>
|
||||||
setFilters((s) => ({
|
setFilters((s) => ({
|
||||||
...s,
|
...s,
|
||||||
hasSpecialFeature: e.target.checked,
|
hasSpecialFeature: e.target.checked,
|
||||||
@@ -1042,7 +1096,9 @@ function LibraryView() {
|
|||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={filters.hasThemeSong}
|
checked={filters.hasThemeSong}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) =>
|
||||||
setFilters((s) => ({
|
setFilters((s) => ({
|
||||||
...s,
|
...s,
|
||||||
hasThemeSong: e.target.checked,
|
hasThemeSong: e.target.checked,
|
||||||
@@ -1056,7 +1112,9 @@ function LibraryView() {
|
|||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={filters.hasThemeVideo}
|
checked={filters.hasThemeVideo}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) =>
|
||||||
setFilters((s) => ({
|
setFilters((s) => ({
|
||||||
...s,
|
...s,
|
||||||
hasThemeVideo: e.target.checked,
|
hasThemeVideo: e.target.checked,
|
||||||
@@ -1067,6 +1125,10 @@ function LibraryView() {
|
|||||||
label="Theme Video"
|
label="Theme Video"
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{currentViewType !== "Audio" && (
|
||||||
|
<div>
|
||||||
<Typography
|
<Typography
|
||||||
variant="h6"
|
variant="h6"
|
||||||
fontWeight={600}
|
fontWeight={600}
|
||||||
@@ -1087,7 +1149,9 @@ function LibraryView() {
|
|||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={videoTypesState.BluRay}
|
checked={videoTypesState.BluRay}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) =>
|
||||||
setVideoTypesState((s) => ({
|
setVideoTypesState((s) => ({
|
||||||
...s,
|
...s,
|
||||||
BluRay: e.target.checked,
|
BluRay: e.target.checked,
|
||||||
@@ -1101,7 +1165,9 @@ function LibraryView() {
|
|||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={videoTypesState.Dvd}
|
checked={videoTypesState.Dvd}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) =>
|
||||||
setVideoTypesState((s) => ({
|
setVideoTypesState((s) => ({
|
||||||
...s,
|
...s,
|
||||||
Dvd: e.target.checked,
|
Dvd: e.target.checked,
|
||||||
@@ -1115,7 +1181,9 @@ function LibraryView() {
|
|||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={filters.isHD}
|
checked={filters.isHD}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) => {
|
||||||
setFilters((s) => ({
|
setFilters((s) => ({
|
||||||
...s,
|
...s,
|
||||||
isHD: e.target.checked,
|
isHD: e.target.checked,
|
||||||
@@ -1129,7 +1197,9 @@ function LibraryView() {
|
|||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={filters.is4K}
|
checked={filters.is4K}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
onChange={(
|
||||||
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
|
) =>
|
||||||
setFilters((s) => ({
|
setFilters((s) => ({
|
||||||
...s,
|
...s,
|
||||||
is4K: e.target.checked,
|
is4K: e.target.checked,
|
||||||
@@ -1159,8 +1229,51 @@ function LibraryView() {
|
|||||||
label="3D"
|
label="3D"
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{genres.isSuccess &&
|
||||||
|
(genres.data?.TotalRecordCount ?? 0) > 0 && (
|
||||||
|
<div>
|
||||||
|
<Typography
|
||||||
|
variant="h6"
|
||||||
|
fontWeight={600}
|
||||||
|
mx="0.4em"
|
||||||
|
mb={0.5}
|
||||||
|
>
|
||||||
|
Genres
|
||||||
|
</Typography>
|
||||||
|
<FormControl
|
||||||
|
style={{
|
||||||
|
background: "rgb(0 0 0 / 0.4)",
|
||||||
|
width: "100%",
|
||||||
|
padding: "0.4em 1em",
|
||||||
|
borderRadius: "6px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{genres.data?.Items?.map(
|
||||||
|
(genre) =>
|
||||||
|
genre.Id && (
|
||||||
|
<FormControlLabel
|
||||||
|
key={genre.Id}
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={genreFilter.includes(
|
||||||
|
genre.Id,
|
||||||
|
)}
|
||||||
|
onChange={(e) =>
|
||||||
|
handleGenreFilter(e, genre)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={genre.Name}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</Menu>
|
</Menu>
|
||||||
</>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
@@ -1174,18 +1287,6 @@ function LibraryView() {
|
|||||||
"Install the trailers channel to enhance your movie experience by adding a library of internet trailers."
|
"Install the trailers channel to enhance your movie experience by adding a library of internet trailers."
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : currentViewType === BaseItemKind.Genre ? (
|
|
||||||
items.data?.Items?.map((item) => {
|
|
||||||
return (
|
|
||||||
<GenreView
|
|
||||||
key={item.Id}
|
|
||||||
libraryId={currentLib.data.Id}
|
|
||||||
genreId={item.Id}
|
|
||||||
genreName={item.Name}
|
|
||||||
userId={user?.Id}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
) : currentViewType !== BaseItemKind.Audio ? (
|
) : currentViewType !== BaseItemKind.Audio ? (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@@ -1204,6 +1305,7 @@ function LibraryView() {
|
|||||||
);
|
);
|
||||||
for (let i = fromIndex; i < toIndex; i++) {
|
for (let i = fromIndex; i < toIndex; i++) {
|
||||||
const item = items.data?.Items?.[i];
|
const item = items.data?.Items?.[i];
|
||||||
|
if (!item) return null;
|
||||||
displayItems.push(
|
displayItems.push(
|
||||||
<div
|
<div
|
||||||
className="library-virtual-item"
|
className="library-virtual-item"
|
||||||
@@ -1212,7 +1314,7 @@ function LibraryView() {
|
|||||||
ref={virtualizer.measureElement}
|
ref={virtualizer.measureElement}
|
||||||
>
|
>
|
||||||
<Card
|
<Card
|
||||||
item={item ?? null}
|
item={item}
|
||||||
seriesId={item?.SeriesId}
|
seriesId={item?.SeriesId}
|
||||||
cardTitle={
|
cardTitle={
|
||||||
item?.Type === BaseItemKind.Episode
|
item?.Type === BaseItemKind.Episode
|
||||||
@@ -1286,6 +1388,7 @@ function LibraryView() {
|
|||||||
>
|
>
|
||||||
{rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
{rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
||||||
const item = items.data?.Items?.[virtualRow.index];
|
const item = items.data?.Items?.[virtualRow.index];
|
||||||
|
if (!item) return null;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={item?.Id}
|
key={item?.Id}
|
||||||
@@ -1299,31 +1402,8 @@ function LibraryView() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<MusicTrack
|
<MusicTrack
|
||||||
item={item ?? null}
|
item={item}
|
||||||
// queryKey={[
|
queryKey={["library"]}
|
||||||
// "libraryView",
|
|
||||||
// "currentLibItems",
|
|
||||||
// id,
|
|
||||||
// {
|
|
||||||
// currentViewType: currentViewType,
|
|
||||||
// sortAscending: sortAscending,
|
|
||||||
// sortBy: sortBy,
|
|
||||||
// extraFilters: {
|
|
||||||
// hasSubtitles: hasSubtitles,
|
|
||||||
// hasTrailer: hasTrailer,
|
|
||||||
// hasSpecialFeature: hasSpecialFeature,
|
|
||||||
// hasThemeSong: hasThemeSong,
|
|
||||||
// hasThemeVideo: hasThemeVideo,
|
|
||||||
// },
|
|
||||||
// qualityFilters: {
|
|
||||||
// isBluRay: isBluRay,
|
|
||||||
// isDVD: isDVD,
|
|
||||||
// isHD: isHD,
|
|
||||||
// is4K: is4K,
|
|
||||||
// is3D: is3D,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// ]}
|
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -1341,5 +1421,3 @@ function LibraryView() {
|
|||||||
return <ErrorNotice error={currentLib.error} />;
|
return <ErrorNotice error={currentLib.error} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default LibraryView;
|
|
||||||
Reference in new issue
Block a user