refactor: change GenreView to genreFilter

This commit is contained in:
Prayag Prajapati committed 2024-11-28 22:05:17 +05:30
1 parent a198e09864
commit 98078585d6
8 files changed
+389 -552

No files matched your search

-1
View File
@@ -1,5 +1,4 @@
{
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
"build": {
"beforeBuildCommand": "pnpm run build",
"beforeDevCommand": "pnpm run dev",
+1 -1
View File
@@ -379,7 +379,7 @@ const PlayButton = ({
// Subtitle
const subtitle = getSubtitle(
currentSubTrack,
result?.mediaSource?.MediaSources?.[0].MediaStreams,
result?.mediaSource?.MediaSources?.[0]?.MediaStreams,
);
// URL generation
const urlOptions: URLSearchParams = {
@@ -10,7 +10,6 @@ import {
type BaseItemDto,
BaseItemKind,
} 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";
/**
@@ -22,8 +21,9 @@ export const LatestMediaSection = ({
const api = useApiInContext((s) => s.api);
const user = useCentralStore((s) => s.currentUser);
const fetchLatestMedia = async (library: BaseItemDto) => {
if (!api || !user?.Id) return null;
const media = await getUserLibraryApi(api).getLatestMedia({
userId: user?.Id,
userId: user.Id,
parentId: library.Id,
limit: 16,
fields: ["PrimaryImageAspectRatio", "ParentId"],
@@ -39,10 +39,10 @@ export const LatestMediaSection = ({
if (data.isPending) {
return <CardsSkeleton />;
}
if (data.isSuccess && data.data.length >= 1) {
if (data.isSuccess && (data.data?.length ?? 0) >= 1) {
return (
<CardScroller displayCards={7} title={`Latest ${latestMediaLib.Name}`}>
{data.data.map((item) => {
{data.data?.map((item) => {
return (
<Card
key={item.Id}
@@ -73,14 +73,8 @@ export const LatestMediaSection = ({
? "square"
: "portrait"
}
queryKey={["home", "latestMedia", latestMediaLib.Id]}
queryKey={["home", "latestMedia", latestMediaLib.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;
}
}
-13
View File
@@ -11,22 +11,9 @@ import { useApiInContext } from "@/utils/store/api";
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
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
* @param {Props}
* @returns {React.Component}
*/
const MusicTrack = ({
item,
queryKey,
+383 -305
View File
@@ -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 { getStudiosApi } from "@jellyfin/sdk/lib/utils/api/studios-api";
import GenreView from "@/components/layouts/library/genreView";
import MusicTrack from "@/components/musicTrack";
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
import { useBackdropStore } from "@/utils/store/backdrop";
import {
type BaseItemDto,
type BaseItemDtoQueryResult,
BaseItemKind,
CollectionType,
@@ -43,13 +43,7 @@ import {
} from "@jellyfin/sdk/lib/generated-client";
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
import {
FormControl,
Menu,
Select,
Stack,
useScrollTrigger,
} from "@mui/material";
import { FormControl, Menu, Stack, useScrollTrigger } from "@mui/material";
import { useWindowVirtualizer } from "@tanstack/react-virtual";
import type { AxiosResponse } from "axios";
import "./library.scss";
@@ -83,10 +77,10 @@ const useWindowWidth = () => {
};
export const Route = createFileRoute("/_api/library/$id")({
component: LibraryView,
component: Library,
});
function LibraryView() {
function Library() {
const api = useApiInContext((s) => s.api);
const { id } = Route.useParams();
@@ -94,8 +88,9 @@ function LibraryView() {
const user = useCentralStore((s) => s.currentUser);
const currentLib = useQuery({
queryKey: ["libraryView", "currentLib", id],
queryKey: ["library", "currentLib", id],
queryFn: async () => {
if (!api) return null;
const result = await getUserLibraryApi(api).getItem({
userId: user?.Id,
itemId: id,
@@ -107,9 +102,58 @@ function LibraryView() {
staleTime: 0,
});
const [currentViewType, setCurrentViewType] = useState<BaseItemKind | "Artist">(
undefined!,
const genres = useQuery({
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(() => {
let result: ViewObject[] = undefined!;
switch (currentLib.data?.CollectionType) {
@@ -486,7 +530,7 @@ function LibraryView() {
const items = useQuery({
queryKey: [
"libraryView",
"library",
"currentLibItems",
id,
{
@@ -495,9 +539,11 @@ function LibraryView() {
sortBy: sortBy,
filters,
videoTypesState,
genreFilter,
},
],
queryFn: async () => {
if (!api) return null;
let result: AxiosResponse<BaseItemDtoQueryResult, any>;
if (currentViewType === "MusicArtist") {
result = await getArtistsApi(api).getAlbumArtists({
@@ -514,16 +560,6 @@ function LibraryView() {
userId: user?.Id,
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") {
result = await getStudiosApi(api).getStudios({
userId: user?.Id,
@@ -563,6 +599,7 @@ function LibraryView() {
is4K: filters.is4K || undefined,
is3D: filters.is3D || undefined,
enableUserData: true,
genreIds: genreFilter,
});
} else {
const videoTypes: VideoType[] = [];
@@ -598,14 +635,13 @@ function LibraryView() {
is4K: filters.is4K || undefined,
is3D: filters.is3D || undefined,
enableUserData: true,
genreIds: genreFilter,
});
}
return result.data;
},
// enabled: false,
enabled: !!user?.Id && Boolean(currentViewType) && currentLib.isSuccess,
networkMode: "always",
// gcTime: 0,
});
const disableSort = useMemo(() => {
@@ -646,7 +682,7 @@ function LibraryView() {
? 260
: 356,
[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 itemsPerRow = useMemo(
() => Math.max(1, Math.floor(windowWidth / 200)),
@@ -694,10 +730,10 @@ function LibraryView() {
const backdropItems = useMemo(() => {
if (items.isSuccess) {
const temp = items.data.Items?.filter(
const temp = items.data?.Items?.filter(
(item) => item.BackdropImageTags?.length,
);
if (temp?.[0]?.Id) {
if (temp?.[0]?.Id && api) {
setBackdrop(
getImageUrlsApi(api).getItemImageUrlById(temp?.[0]?.Id, "Backdrop", {
tag: temp?.[0]?.BackdropImageTags?.[0],
@@ -710,7 +746,7 @@ function LibraryView() {
}, [items]);
useEffect(() => {
if (backdropItems?.length) {
if (backdropItems?.length && api) {
const intervalId = setInterval(() => {
const itemIndex = Math.floor(Math.random() * backdropItems?.length);
const backdropItem = backdropItems[itemIndex];
@@ -730,8 +766,6 @@ function LibraryView() {
}
}, [backdropItems]);
const [test, setTest] = useState(1);
if (items.isError) {
console.error(items.error);
}
@@ -778,7 +812,7 @@ function LibraryView() {
{currentLib.isPending ? (
<CircularProgress sx={{ p: 1 }} />
) : (
currentLib.data.Name
currentLib.data?.Name
)}
</Typography>
<Chip
@@ -786,7 +820,7 @@ function LibraryView() {
!items.isSuccess ? (
<CircularProgress sx={{ p: 1.5 }} />
) : (
items.data.TotalRecordCount
items.data?.TotalRecordCount
)
}
/>
@@ -880,7 +914,7 @@ function LibraryView() {
</TextField>
)}
{!disableFilters && (
<>
<div>
<Button
startIcon={
<span className="material-symbols-rounded">
@@ -907,260 +941,339 @@ function LibraryView() {
},
}}
>
<Typography
variant="h6"
fontWeight={600}
mx="0.4em"
mb={0.5}
>
Filters
</Typography>
<FormControl
style={{
background: "rgb(0 0 0 / 0.4)",
width: "100%",
padding: "0.4em 1em",
borderRadius: "6px",
}}
>
<FormControlLabel
control={
<Checkbox
checked={filters.isPlayed}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
setFilters((s) => ({
...s,
isPlayed: e.target.checked,
}))
{currentViewType !== "Audio" && (
<div>
<Typography
variant="h6"
fontWeight={600}
mx="0.4em"
mb={0.5}
>
Filters
</Typography>
<FormControl
style={{
background: "rgb(0 0 0 / 0.4)",
width: "100%",
padding: "0.4em 1em",
borderRadius: "6px",
}}
>
<FormControlLabel
control={
<Checkbox
checked={filters.isPlayed}
onChange={(
e: ChangeEvent<HTMLInputElement>,
) =>
setFilters((s) => ({
...s,
isPlayed: e.target.checked,
}))
}
/>
}
label="Played"
/>
}
label="Played"
/>
<FormControlLabel
control={
<Checkbox
checked={filters.isUnPlayed}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
setFilters((s) => ({
...s,
isUnPlayed: e.target.checked,
}))
<FormControlLabel
control={
<Checkbox
checked={filters.isUnPlayed}
onChange={(
e: ChangeEvent<HTMLInputElement>,
) =>
setFilters((s) => ({
...s,
isUnPlayed: e.target.checked,
}))
}
/>
}
label="Unplayed"
/>
}
label="Unplayed"
/>
<FormControlLabel
control={
<Checkbox
checked={filters.isResumable}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
setFilters((s) => ({
...s,
isResumable: e.target.checked,
}))
<FormControlLabel
control={
<Checkbox
checked={filters.isResumable}
onChange={(
e: ChangeEvent<HTMLInputElement>,
) =>
setFilters((s) => ({
...s,
isResumable: e.target.checked,
}))
}
/>
}
label="Resumable"
/>
}
label="Resumable"
/>
<FormControlLabel
control={
<Checkbox
checked={filters.isFavorite}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
setFilters((s) => ({
...s,
isFavorite: e.target.checked,
}))
<FormControlLabel
control={
<Checkbox
checked={filters.isFavorite}
onChange={(
e: ChangeEvent<HTMLInputElement>,
) =>
setFilters((s) => ({
...s,
isFavorite: e.target.checked,
}))
}
/>
}
label="Favorites"
/>
}
label="Favorites"
/>
</FormControl>
<Typography
variant="h6"
fontWeight={600}
mx="0.4em"
mb={0.5}
>
Features
</Typography>
<FormControl
style={{
background: "rgb(0 0 0 / 0.4)",
width: "100%",
padding: "0.4em 1em",
borderRadius: "6px",
}}
>
<FormControlLabel
control={
<Checkbox
checked={filters.hasSubtitles}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
setFilters((s) => ({
...s,
hasSubtitles: e.target.checked,
}))
</FormControl>
</div>
)}
{currentViewType !== "Audio" && (
<div>
<Typography
variant="h6"
fontWeight={600}
mx="0.4em"
mb={0.5}
>
Features
</Typography>
<FormControl
style={{
background: "rgb(0 0 0 / 0.4)",
width: "100%",
padding: "0.4em 1em",
borderRadius: "6px",
}}
>
<FormControlLabel
control={
<Checkbox
checked={filters.hasSubtitles}
onChange={(
e: ChangeEvent<HTMLInputElement>,
) =>
setFilters((s) => ({
...s,
hasSubtitles: e.target.checked,
}))
}
/>
}
label="Subtitles"
/>
}
label="Subtitles"
/>
<FormControlLabel
control={
<Checkbox
checked={filters.hasTrailer}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
setFilters((s) => ({
...s,
hasTrailer: e.target.checked,
}))
<FormControlLabel
control={
<Checkbox
checked={filters.hasTrailer}
onChange={(
e: ChangeEvent<HTMLInputElement>,
) =>
setFilters((s) => ({
...s,
hasTrailer: e.target.checked,
}))
}
/>
}
label="Trailer"
/>
}
label="Trailer"
/>
<FormControlLabel
control={
<Checkbox
checked={filters.hasSpecialFeature}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
setFilters((s) => ({
...s,
hasSpecialFeature: e.target.checked,
}))
<FormControlLabel
control={
<Checkbox
checked={filters.hasSpecialFeature}
onChange={(
e: ChangeEvent<HTMLInputElement>,
) =>
setFilters((s) => ({
...s,
hasSpecialFeature: e.target.checked,
}))
}
/>
}
label="Special Features"
/>
}
label="Special Features"
/>
<FormControlLabel
control={
<Checkbox
checked={filters.hasThemeSong}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
setFilters((s) => ({
...s,
hasThemeSong: e.target.checked,
}))
<FormControlLabel
control={
<Checkbox
checked={filters.hasThemeSong}
onChange={(
e: ChangeEvent<HTMLInputElement>,
) =>
setFilters((s) => ({
...s,
hasThemeSong: e.target.checked,
}))
}
/>
}
label="Theme Song"
/>
}
label="Theme Song"
/>
<FormControlLabel
control={
<Checkbox
checked={filters.hasThemeVideo}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
setFilters((s) => ({
...s,
hasThemeVideo: e.target.checked,
}))
<FormControlLabel
control={
<Checkbox
checked={filters.hasThemeVideo}
onChange={(
e: ChangeEvent<HTMLInputElement>,
) =>
setFilters((s) => ({
...s,
hasThemeVideo: e.target.checked,
}))
}
/>
}
label="Theme Video"
/>
}
label="Theme Video"
/>
</FormControl>
<Typography
variant="h6"
fontWeight={600}
mx="0.4em"
mb={0.5}
>
Video Types
</Typography>
<FormControl
style={{
background: "rgb(0 0 0 / 0.4)",
width: "100%",
padding: "0.4em 1em",
borderRadius: "6px",
}}
>
<FormControlLabel
control={
<Checkbox
checked={videoTypesState.BluRay}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
setVideoTypesState((s) => ({
...s,
BluRay: e.target.checked,
}))
</FormControl>
</div>
)}
{currentViewType !== "Audio" && (
<div>
<Typography
variant="h6"
fontWeight={600}
mx="0.4em"
mb={0.5}
>
Video Types
</Typography>
<FormControl
style={{
background: "rgb(0 0 0 / 0.4)",
width: "100%",
padding: "0.4em 1em",
borderRadius: "6px",
}}
>
<FormControlLabel
control={
<Checkbox
checked={videoTypesState.BluRay}
onChange={(
e: ChangeEvent<HTMLInputElement>,
) =>
setVideoTypesState((s) => ({
...s,
BluRay: e.target.checked,
}))
}
/>
}
label="BluRay"
/>
}
label="BluRay"
/>
<FormControlLabel
control={
<Checkbox
checked={videoTypesState.Dvd}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
setVideoTypesState((s) => ({
...s,
Dvd: e.target.checked,
}))
<FormControlLabel
control={
<Checkbox
checked={videoTypesState.Dvd}
onChange={(
e: ChangeEvent<HTMLInputElement>,
) =>
setVideoTypesState((s) => ({
...s,
Dvd: e.target.checked,
}))
}
/>
}
label="DVD"
/>
}
label="DVD"
/>
<FormControlLabel
control={
<Checkbox
checked={filters.isHD}
onChange={(e: ChangeEvent<HTMLInputElement>) => {
setFilters((s) => ({
...s,
isHD: e.target.checked,
}));
<FormControlLabel
control={
<Checkbox
checked={filters.isHD}
onChange={(
e: ChangeEvent<HTMLInputElement>,
) => {
setFilters((s) => ({
...s,
isHD: e.target.checked,
}));
}}
/>
}
label="HD"
/>
<FormControlLabel
control={
<Checkbox
checked={filters.is4K}
onChange={(
e: ChangeEvent<HTMLInputElement>,
) =>
setFilters((s) => ({
...s,
is4K: e.target.checked,
}))
}
/>
}
label="4k"
/>
<FormControlLabel
control={<Checkbox checked={false} />}
label="SD"
disabled
/>
<FormControlLabel
control={
<Checkbox
value={filters.is3D}
onChange={(e) =>
setFilters((s) => ({
...s,
is3D: e.target.checked,
}))
}
/>
}
label="3D"
/>
</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",
}}
/>
}
label="HD"
/>
<FormControlLabel
control={
<Checkbox
checked={filters.is4K}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
setFilters((s) => ({
...s,
is4K: e.target.checked,
}))
}
/>
}
label="4k"
/>
<FormControlLabel
control={<Checkbox checked={false} />}
label="SD"
disabled
/>
<FormControlLabel
control={
<Checkbox
value={filters.is3D}
onChange={(e) =>
setFilters((s) => ({
...s,
is3D: e.target.checked,
}))
}
/>
}
label="3D"
/>
</FormControl>
>
{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>
</>
</div>
)}
</Stack>
</div>
@@ -1174,18 +1287,6 @@ function LibraryView() {
"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 ? (
<div
style={{
@@ -1204,6 +1305,7 @@ function LibraryView() {
);
for (let i = fromIndex; i < toIndex; i++) {
const item = items.data?.Items?.[i];
if (!item) return null;
displayItems.push(
<div
className="library-virtual-item"
@@ -1212,7 +1314,7 @@ function LibraryView() {
ref={virtualizer.measureElement}
>
<Card
item={item ?? null}
item={item}
seriesId={item?.SeriesId}
cardTitle={
item?.Type === BaseItemKind.Episode
@@ -1286,6 +1388,7 @@ function LibraryView() {
>
{rowVirtualizer.getVirtualItems().map((virtualRow) => {
const item = items.data?.Items?.[virtualRow.index];
if (!item) return null;
return (
<div
key={item?.Id}
@@ -1299,31 +1402,8 @@ function LibraryView() {
}}
>
<MusicTrack
item={item ?? null}
// queryKey={[
// "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,
// },
// },
// ]}
item={item}
queryKey={["library"]}
userId={user?.Id}
/>
</div>
@@ -1341,5 +1421,3 @@ function LibraryView() {
return <ErrorNotice error={currentLib.error} />;
}
}
export default LibraryView;