From 4cb54bc9dac17676fea3dfbd327659a8cbb8106e Mon Sep 17 00:00:00 2001 From: jeffvli Date: Wed, 17 May 2023 21:07:04 -0700 Subject: [PATCH] Fix misc types --- src/renderer/api/jellyfin/jellyfin-types.ts | 28 ++++++++++--------- src/renderer/api/navidrome/navidrome-types.ts | 3 ++ src/renderer/api/types.ts | 10 +++++-- .../components/jellyfin-album-filters.tsx | 14 +++++----- .../components/jellyfin-song-filters.tsx | 18 ++++++------ 5 files changed, 42 insertions(+), 31 deletions(-) diff --git a/src/renderer/api/jellyfin/jellyfin-types.ts b/src/renderer/api/jellyfin/jellyfin-types.ts index d4d275ac..374b9eee 100644 --- a/src/renderer/api/jellyfin/jellyfin-types.ts +++ b/src/renderer/api/jellyfin/jellyfin-types.ts @@ -524,19 +524,21 @@ const jfSongListSort = { RELEASE_DATE: 'PremiereDate,AlbumArtist,Album,SortName', } as const; -const songListParameters = baseParameters.extend({ - AlbumArtistIds: z.string().optional(), - AlbumIds: z.string().optional(), - ArtistIds: z.string().optional(), - Filters: z.string().optional(), - GenreIds: z.string().optional(), - Genres: z.string().optional(), - IsFavorite: z.boolean().optional(), - SearchTerm: z.string().optional(), - SortBy: z.nativeEnum(jfSongListSort).optional(), - Tags: z.string().optional(), - Years: z.string().optional(), -}); +const songListParameters = paginationParameters.merge( + baseParameters.extend({ + AlbumArtistIds: z.string().optional(), + AlbumIds: z.string().optional(), + ArtistIds: z.string().optional(), + Filters: z.string().optional(), + GenreIds: z.string().optional(), + Genres: z.string().optional(), + IsFavorite: z.boolean().optional(), + SearchTerm: z.string().optional(), + SortBy: z.nativeEnum(jfSongListSort).optional(), + Tags: z.string().optional(), + Years: z.string().optional(), + }), +); const songList = pagination.extend({ Items: z.array(song), diff --git a/src/renderer/api/navidrome/navidrome-types.ts b/src/renderer/api/navidrome/navidrome-types.ts index 2bba9080..a6d4d3a1 100644 --- a/src/renderer/api/navidrome/navidrome-types.ts +++ b/src/renderer/api/navidrome/navidrome-types.ts @@ -156,6 +156,7 @@ const albumListParameters = paginationParameters.extend({ id: z.string().optional(), name: z.string().optional(), recently_added: z.boolean().optional(), + recently_played: z.boolean().optional(), starred: z.boolean().optional(), year: z.number().optional(), }); @@ -236,6 +237,8 @@ const songListParameters = paginationParameters.extend({ artist_id: z.array(z.string()).optional(), genre_id: z.string().optional(), starred: z.boolean().optional(), + title: z.string().optional(), + year: z.number().optional(), }); const playlist = z.object({ diff --git a/src/renderer/api/types.ts b/src/renderer/api/types.ts index 3a251b66..3e79dec1 100644 --- a/src/renderer/api/types.ts +++ b/src/renderer/api/types.ts @@ -316,7 +316,10 @@ export enum AlbumListSort { export type AlbumListQuery = { _custom?: { - jellyfin?: Partial>; + jellyfin?: Partial> & { + maxYear?: number; + minYear?: number; + }; navidrome?: Partial>; }; artistIds?: string[]; @@ -423,7 +426,10 @@ export enum SongListSort { export type SongListQuery = { _custom?: { - jellyfin?: Partial>; + jellyfin?: Partial> & { + maxYear?: number; + minYear?: number; + }; navidrome?: Partial>; }; albumIds?: string[]; diff --git a/src/renderer/features/albums/components/jellyfin-album-filters.tsx b/src/renderer/features/albums/components/jellyfin-album-filters.tsx index aacfdb5d..ace5581c 100644 --- a/src/renderer/features/albums/components/jellyfin-album-filters.tsx +++ b/src/renderer/features/albums/components/jellyfin-album-filters.tsx @@ -37,8 +37,8 @@ export const JellyfinAlbumFilters = ({ }, [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 = [ { @@ -50,7 +50,7 @@ export const JellyfinAlbumFilters = ({ ...filter._custom, jellyfin: { ...filter._custom?.jellyfin, - isFavorite: e.currentTarget.checked ? true : undefined, + IsFavorite: e.currentTarget.checked ? true : undefined, }, }, }, @@ -58,7 +58,7 @@ export const JellyfinAlbumFilters = ({ }) as AlbumListFilter; handleFilterChange(updatedFilters); }, - value: filter._custom?.jellyfin?.isFavorite, + value: filter._custom?.jellyfin?.IsFavorite, }, ]; @@ -104,7 +104,7 @@ export const JellyfinAlbumFilters = ({ ...filter._custom, jellyfin: { ...filter._custom?.jellyfin, - genreIds: genreFilterString, + GenreIds: genreFilterString, }, }, }, @@ -145,7 +145,7 @@ export const JellyfinAlbumFilters = ({ ...filter._custom, jellyfin: { ...filter._custom?.jellyfin, - albumArtistIds: albumArtistFilterString, + AlbumArtistIds: albumArtistFilterString, }, }, }, @@ -206,7 +206,7 @@ export const JellyfinAlbumFilters = ({ clearable searchable data={selectableAlbumArtists} - defaultValue={filter._custom?.jellyfin?.albumArtistIds?.split(',')} + defaultValue={filter._custom?.jellyfin?.AlbumArtistIds?.split(',')} disabled={disableArtistFilter} label="Artist" limit={300} diff --git a/src/renderer/features/songs/components/jellyfin-song-filters.tsx b/src/renderer/features/songs/components/jellyfin-song-filters.tsx index 8bfa0d38..759b148c 100644 --- a/src/renderer/features/songs/components/jellyfin-song-filters.tsx +++ b/src/renderer/features/songs/components/jellyfin-song-filters.tsx @@ -33,8 +33,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 = [ { @@ -46,8 +46,8 @@ export const JellyfinSongFilters = ({ ...filter._custom, jellyfin: { ...filter._custom?.jellyfin, - includeItemTypes: 'Audio', - isFavorite: e.currentTarget.checked ? true : undefined, + IncludeItemTypes: 'Audio', + IsFavorite: e.currentTarget.checked ? true : undefined, }, }, }, @@ -55,7 +55,7 @@ export const JellyfinSongFilters = ({ }) as SongListFilter; handleFilterChange(updatedFilters); }, - value: filter._custom?.jellyfin?.isFavorite, + value: filter._custom?.jellyfin?.IsFavorite, }, ]; @@ -67,7 +67,7 @@ export const JellyfinSongFilters = ({ ...filter._custom, jellyfin: { ...filter._custom?.jellyfin, - includeItemTypes: 'Audio', + IncludeItemTypes: 'Audio', minYear: e === '' ? undefined : (e as number), }, }, @@ -85,7 +85,7 @@ export const JellyfinSongFilters = ({ ...filter._custom, jellyfin: { ...filter._custom?.jellyfin, - includeItemTypes: 'Audio', + IncludeItemTypes: 'Audio', maxYear: e === '' ? undefined : (e as number), }, }, @@ -103,8 +103,8 @@ export const JellyfinSongFilters = ({ ...filter._custom, jellyfin: { ...filter._custom?.jellyfin, - genreIds: genreFilterString, - includeItemTypes: 'Audio', + GenreIds: genreFilterString, + IncludeItemTypes: 'Audio', }, }, },