From f81bea339b88c66a9676edb895653f488b18fa32 Mon Sep 17 00:00:00 2001 From: Kendall Garner <17521368+kgarner7@users.noreply.github.com> Date: Mon, 19 Feb 2024 09:55:37 -0800 Subject: [PATCH] don't pass song all the way down --- src/renderer/api/jellyfin/jellyfin-controller.ts | 2 +- src/renderer/api/subsonic/subsonic-controller.ts | 2 +- src/renderer/api/types.ts | 2 +- .../components/full-screen-similar-songs.tsx | 4 ++-- .../components/similar-songs-list.tsx | 16 +++++++--------- .../queries/similar-song-queries.tsx | 11 +++++------ 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/renderer/api/jellyfin/jellyfin-controller.ts b/src/renderer/api/jellyfin/jellyfin-controller.ts index 6e2a3a71..d795abc7 100644 --- a/src/renderer/api/jellyfin/jellyfin-controller.ts +++ b/src/renderer/api/jellyfin/jellyfin-controller.ts @@ -967,7 +967,7 @@ const getSimilarSongs = async (args: SimilarSongsArgs): Promise => { const res = await jfApiClient(apiClientProps).getSimilarSongs({ params: { - itemId: query.song.id, + itemId: query.songId, }, query: { Fields: 'Genres, DateCreated, MediaSources, ParentId', diff --git a/src/renderer/api/subsonic/subsonic-controller.ts b/src/renderer/api/subsonic/subsonic-controller.ts index 4edf5b13..4aa123a1 100644 --- a/src/renderer/api/subsonic/subsonic-controller.ts +++ b/src/renderer/api/subsonic/subsonic-controller.ts @@ -452,7 +452,7 @@ const getSimilarSongs = async (args: SimilarSongsArgs): Promise => { const res = await ssApiClient(apiClientProps).getSimilarSongs({ query: { count: query.count, - id: query.song.id, + id: query.songId, }, }); diff --git a/src/renderer/api/types.ts b/src/renderer/api/types.ts index 8aff013b..c4e3c515 100644 --- a/src/renderer/api/types.ts +++ b/src/renderer/api/types.ts @@ -1173,7 +1173,7 @@ export type StructuredLyric = { export type SimilarSongsQuery = { count?: number; - song: Song; + songId: string; }; export type SimilarSongsArgs = { diff --git a/src/renderer/features/player/components/full-screen-similar-songs.tsx b/src/renderer/features/player/components/full-screen-similar-songs.tsx index 16f96628..c03f62c5 100644 --- a/src/renderer/features/player/components/full-screen-similar-songs.tsx +++ b/src/renderer/features/player/components/full-screen-similar-songs.tsx @@ -4,10 +4,10 @@ import { useCurrentSong } from '/@/renderer/store'; export const FullScreenSimilarSongs = () => { const currentSong = useCurrentSong(); - return ( + return currentSong ? ( - ); + ) : null; }; diff --git a/src/renderer/features/similar-songs/components/similar-songs-list.tsx b/src/renderer/features/similar-songs/components/similar-songs-list.tsx index 5a7021e8..3a1595db 100644 --- a/src/renderer/features/similar-songs/components/similar-songs-list.tsx +++ b/src/renderer/features/similar-songs/components/similar-songs-list.tsx @@ -16,7 +16,7 @@ import { useHandlePlayQueueAdd } from '/@/renderer/features/player/hooks/use-han export type SimilarSongsListProps = { count?: number; fullScreen?: boolean; - song?: Song; + song: Song; }; export const SimilarSongsList = ({ count, fullScreen, song }: SimilarSongsListProps) => { @@ -30,8 +30,8 @@ export const SimilarSongsList = ({ count, fullScreen, song }: SimilarSongsListPr cacheTime: 1000 * 60 * 2, staleTime: 1000 * 60 * 1, }, - query: { count, song }, - serverId: undefined, + query: { count, songId: song.id }, + serverId: song?.serverId, }); const columnDefs = useMemo( @@ -52,12 +52,10 @@ export const SimilarSongsList = ({ count, fullScreen, song }: SimilarSongsListPr }; return songQuery.isLoading ? ( - song ? ( - - ) : undefined + ) : ( diff --git a/src/renderer/features/similar-songs/queries/similar-song-queries.tsx b/src/renderer/features/similar-songs/queries/similar-song-queries.tsx index ead70817..0ba4516a 100644 --- a/src/renderer/features/similar-songs/queries/similar-song-queries.tsx +++ b/src/renderer/features/similar-songs/queries/similar-song-queries.tsx @@ -5,19 +5,18 @@ import { getServerById } from '/@/renderer/store'; import { queryKeys } from '/@/renderer/api/query-keys'; import { api } from '/@/renderer/api'; -export const useSimilarSongs = (args: QueryHookArgs>) => { - const { options, query } = args || {}; - const server = getServerById(query.song?.serverId); +export const useSimilarSongs = (args: QueryHookArgs) => { + const { options, query, serverId } = args || {}; + const server = getServerById(serverId); return useQuery({ - enabled: !!server?.id && !!query.song, + enabled: !!server, queryFn: ({ signal }) => { if (!server) throw new Error('Server not found'); - if (!query.song) return undefined; return api.controller.getSimilarSongs({ apiClientProps: { server, signal }, - query: { count: query.count ?? 50, song: query.song }, + query: { count: query.count ?? 50, songId: query.songId }, }); }, queryKey: queryKeys.albumArtists.detail(server?.id || '', query),