Improve genres for jellyfin

- Support music folder
- Add images
- Fix genre filters on album/track filters
This commit is contained in:
jeffvli 2023-08-08 09:18:43 -07:00
parent 3f813b1a26
commit 7c59722f0a
11 changed files with 163 additions and 51 deletions

View file

@ -28,6 +28,7 @@ export const JellyfinSongFilters = ({
// TODO - eventually replace with /items/filters endpoint to fetch genres and tags specific to the selected library
const genreListQuery = useGenreList({
query: {
musicFolderId: filter?.musicFolderId,
sortBy: GenreListSort.NAME,
sortOrder: SortOrder.ASC,
startIndex: 0,
@ -44,8 +45,8 @@ export const JellyfinSongFilters = ({
}, [genreListQuery.data]);
const selectedGenres = useMemo(() => {
return filter._custom?.jellyfin?.GenreIds?.split(',');
}, [filter._custom?.jellyfin?.GenreIds]);
return filter?._custom?.jellyfin?.GenreIds?.split(',');
}, [filter?._custom?.jellyfin?.GenreIds]);
const toggleFilters = [
{
@ -55,9 +56,9 @@ export const JellyfinSongFilters = ({
customFilters,
data: {
_custom: {
...filter._custom,
...filter?._custom,
jellyfin: {
...filter._custom?.jellyfin,
...filter?._custom?.jellyfin,
IncludeItemTypes: 'Audio',
IsFavorite: e.currentTarget.checked ? true : undefined,
},
@ -68,7 +69,7 @@ export const JellyfinSongFilters = ({
}) as SongListFilter;
onFilterChange(updatedFilters);
},
value: filter._custom?.jellyfin?.IsFavorite,
value: filter?._custom?.jellyfin?.IsFavorite,
},
];
@ -78,9 +79,9 @@ export const JellyfinSongFilters = ({
customFilters,
data: {
_custom: {
...filter._custom,
...filter?._custom,
jellyfin: {
...filter._custom?.jellyfin,
...filter?._custom?.jellyfin,
IncludeItemTypes: 'Audio',
minYear: e === '' ? undefined : (e as number),
},
@ -98,9 +99,9 @@ export const JellyfinSongFilters = ({
customFilters,
data: {
_custom: {
...filter._custom,
...filter?._custom,
jellyfin: {
...filter._custom?.jellyfin,
...filter?._custom?.jellyfin,
IncludeItemTypes: 'Audio',
maxYear: e === '' ? undefined : (e as number),
},
@ -118,9 +119,9 @@ export const JellyfinSongFilters = ({
customFilters,
data: {
_custom: {
...filter._custom,
...filter?._custom,
jellyfin: {
...filter._custom?.jellyfin,
...filter?._custom?.jellyfin,
GenreIds: genreFilterString,
IncludeItemTypes: 'Audio',
},
@ -150,14 +151,14 @@ export const JellyfinSongFilters = ({
<Group grow>
<NumberInput
required
defaultValue={filter._custom?.jellyfin?.minYear}
defaultValue={filter?._custom?.jellyfin?.minYear}
label="From year"
max={2300}
min={1700}
onChange={handleMinYearFilter}
/>
<NumberInput
defaultValue={filter._custom?.jellyfin?.maxYear}
defaultValue={filter?._custom?.jellyfin?.maxYear}
label="To year"
max={2300}
min={1700}

View file

@ -1,5 +1,6 @@
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
import { useCallback, useMemo, useRef } from 'react';
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
import isEmpty from 'lodash/isEmpty';
import { useParams, useSearchParams } from 'react-router-dom';
import { GenreListSort, LibraryItem, SongListQuery, SortOrder } from '/@/renderer/api/types';
import { ListContext } from '/@/renderer/context/list-context';
@ -21,8 +22,8 @@ const TrackListRoute = () => {
const pageKey = albumArtistId ? `albumArtistSong` : 'song';
const customFilters: Partial<SongListQuery> = useMemo(() => {
return {
const customFilters = useMemo(() => {
const value = {
...(albumArtistId && { artistIds: [albumArtistId] }),
...(genreId && {
_custom: {
@ -35,6 +36,12 @@ const TrackListRoute = () => {
},
}),
};
if (isEmpty(value)) {
return undefined;
}
return value;
}, [albumArtistId, genreId]);
const handlePlayQueueAdd = usePlayQueueAdd();