omit song from similar list, handle subsonic error
This commit is contained in:
parent
f81bea339b
commit
3a116e938e
4 changed files with 24 additions and 8 deletions
|
@ -980,7 +980,13 @@ const getSimilarSongs = async (args: SimilarSongsArgs): Promise<Song[]> => {
|
||||||
throw new Error('Failed to get similar songs');
|
throw new Error('Failed to get similar songs');
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.body.Items.map((song) => jfNormalize.song(song, apiClientProps.server, ''));
|
return res.body.Items.reduce<Song[]>((acc, song) => {
|
||||||
|
if (song.Id !== query.songId) {
|
||||||
|
acc.push(jfNormalize.song(song, apiClientProps.server, ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const jfController = {
|
export const jfController = {
|
||||||
|
|
|
@ -460,9 +460,17 @@ const getSimilarSongs = async (args: SimilarSongsArgs): Promise<Song[]> => {
|
||||||
throw new Error('Failed to get similar songs');
|
throw new Error('Failed to get similar songs');
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.body.similarSongs.song.map((song) =>
|
if (!res.body.similarSongs) {
|
||||||
ssNormalize.song(song, apiClientProps.server, ''),
|
return [];
|
||||||
);
|
}
|
||||||
|
|
||||||
|
return res.body.similarSongs.song.reduce<Song[]>((acc, song) => {
|
||||||
|
if (song.id !== query.songId) {
|
||||||
|
acc.push(ssNormalize.song(song, apiClientProps.server, ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ssController = {
|
export const ssController = {
|
||||||
|
|
|
@ -253,9 +253,11 @@ const similarSongsParameters = z.object({
|
||||||
});
|
});
|
||||||
|
|
||||||
const similarSongs = z.object({
|
const similarSongs = z.object({
|
||||||
similarSongs: z.object({
|
similarSongs: z
|
||||||
|
.object({
|
||||||
song: z.array(song),
|
song: z.array(song),
|
||||||
}),
|
})
|
||||||
|
.optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ssType = {
|
export const ssType = {
|
||||||
|
|
|
@ -71,7 +71,7 @@ export const SimilarSongsList = ({ count, fullScreen, song }: SimilarSongsListPr
|
||||||
deselectOnClickOutside={fullScreen}
|
deselectOnClickOutside={fullScreen}
|
||||||
getRowId={(data) => data.data.uniqueId}
|
getRowId={(data) => data.data.uniqueId}
|
||||||
rowBuffer={50}
|
rowBuffer={50}
|
||||||
rowData={songQuery.data}
|
rowData={songQuery.data ?? []}
|
||||||
rowHeight={tableConfig.rowHeight || 40}
|
rowHeight={tableConfig.rowHeight || 40}
|
||||||
onCellContextMenu={onCellContextMenu}
|
onCellContextMenu={onCellContextMenu}
|
||||||
onCellDoubleClicked={handleRowDoubleClick}
|
onCellDoubleClicked={handleRowDoubleClick}
|
||||||
|
|
Reference in a new issue