diff --git a/src/renderer/api/jellyfin/jellyfin-controller.ts b/src/renderer/api/jellyfin/jellyfin-controller.ts index d795abc7..cddb0158 100644 --- a/src/renderer/api/jellyfin/jellyfin-controller.ts +++ b/src/renderer/api/jellyfin/jellyfin-controller.ts @@ -980,7 +980,13 @@ const getSimilarSongs = async (args: SimilarSongsArgs): Promise => { throw new Error('Failed to get similar songs'); } - return res.body.Items.map((song) => jfNormalize.song(song, apiClientProps.server, '')); + return res.body.Items.reduce((acc, song) => { + if (song.Id !== query.songId) { + acc.push(jfNormalize.song(song, apiClientProps.server, '')); + } + + return acc; + }, []); }; export const jfController = { diff --git a/src/renderer/api/subsonic/subsonic-controller.ts b/src/renderer/api/subsonic/subsonic-controller.ts index 4aa123a1..75e3435e 100644 --- a/src/renderer/api/subsonic/subsonic-controller.ts +++ b/src/renderer/api/subsonic/subsonic-controller.ts @@ -460,9 +460,17 @@ const getSimilarSongs = async (args: SimilarSongsArgs): Promise => { throw new Error('Failed to get similar songs'); } - return res.body.similarSongs.song.map((song) => - ssNormalize.song(song, apiClientProps.server, ''), - ); + if (!res.body.similarSongs) { + return []; + } + + return res.body.similarSongs.song.reduce((acc, song) => { + if (song.id !== query.songId) { + acc.push(ssNormalize.song(song, apiClientProps.server, '')); + } + + return acc; + }, []); }; export const ssController = { diff --git a/src/renderer/api/subsonic/subsonic-types.ts b/src/renderer/api/subsonic/subsonic-types.ts index b54b9eb1..a9ff3125 100644 --- a/src/renderer/api/subsonic/subsonic-types.ts +++ b/src/renderer/api/subsonic/subsonic-types.ts @@ -253,9 +253,11 @@ const similarSongsParameters = z.object({ }); const similarSongs = z.object({ - similarSongs: z.object({ - song: z.array(song), - }), + similarSongs: z + .object({ + song: z.array(song), + }) + .optional(), }); export const ssType = { 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 3a1595db..1c1dc678 100644 --- a/src/renderer/features/similar-songs/components/similar-songs-list.tsx +++ b/src/renderer/features/similar-songs/components/similar-songs-list.tsx @@ -71,7 +71,7 @@ export const SimilarSongsList = ({ count, fullScreen, song }: SimilarSongsListPr deselectOnClickOutside={fullScreen} getRowId={(data) => data.data.uniqueId} rowBuffer={50} - rowData={songQuery.data} + rowData={songQuery.data ?? []} rowHeight={tableConfig.rowHeight || 40} onCellContextMenu={onCellContextMenu} onCellDoubleClicked={handleRowDoubleClick}