Update album artist detail endpoints

This commit is contained in:
jeffvli 2023-01-08 20:45:38 -08:00
parent ba0ec909c8
commit c51194cd03
4 changed files with 32 additions and 2 deletions

View file

@ -199,6 +199,12 @@ const getGenreList = async (args: GenreListArgs) => {
return (apiController('getGenreList') as ControllerEndpoint['getGenreList'])?.(args);
};
const getAlbumArtistDetail = async (args: AlbumArtistDetailArgs) => {
return (apiController('getAlbumArtistDetail') as ControllerEndpoint['getAlbumArtistDetail'])?.(
args,
);
};
const getAlbumArtistList = async (args: AlbumArtistListArgs) => {
return (apiController('getAlbumArtistList') as ControllerEndpoint['getAlbumArtistList'])?.(args);
};
@ -254,6 +260,7 @@ export const controller = {
createPlaylist,
deleteFavorite,
deletePlaylist,
getAlbumArtistDetail,
getAlbumArtistList,
getAlbumDetail,
getAlbumList,

View file

@ -666,7 +666,7 @@ const normalizeSong = (
playCount: (item.UserData && item.UserData.PlayCount) || 0,
// releaseDate: (item.ProductionYear && new Date(item.ProductionYear, 0, 1).toISOString()) || null,
releaseDate: null,
releaseYear: (item.ProductionYear && String(item.ProductionYear)) || null,
releaseYear: item.ProductionYear ? String(item.ProductionYear) : null,
serverId: server.id,
serverType: ServerType.JELLYFIN,
size: item.MediaSources && item.MediaSources[0]?.Size,

View file

@ -19,6 +19,8 @@ import type {
import { SSGenreList, SSMusicFolderList } from '/@/renderer/api/subsonic.types';
import type {
Album,
AlbumArtist,
RawAlbumArtistDetailResponse,
RawAlbumArtistListResponse,
RawAlbumDetailResponse,
RawAlbumListResponse,
@ -149,6 +151,25 @@ const genreList = (data: RawGenreListResponse | undefined, server: ServerListIte
return genres;
};
const albumArtistDetail = (
data: RawAlbumArtistDetailResponse | undefined,
server: ServerListItem | null,
): AlbumArtist | undefined => {
let albumArtist: AlbumArtist | undefined;
switch (server?.type) {
case 'jellyfin':
albumArtist = jfNormalize.albumArtist(data as JFAlbumArtist, server);
break;
case 'navidrome':
albumArtist = ndNormalize.albumArtist(data as NDAlbumArtist, server);
break;
case 'subsonic':
break;
}
return albumArtist;
};
const albumArtistList = (
data: RawAlbumArtistListResponse | undefined,
server: ServerListItem | null,
@ -235,6 +256,7 @@ const userList = (data: RawUserListResponse | undefined, server: ServerListItem
};
export const normalize = {
albumArtistDetail,
albumArtistList,
albumDetail,
albumList,

View file

@ -8,11 +8,12 @@ import type {
PlaylistDetailQuery,
PlaylistSongListQuery,
UserListQuery,
AlbumArtistDetailQuery,
} from './types';
export const queryKeys = {
albumArtists: {
detail: (serverId: string, query?: AlbumArtistListQuery) => {
detail: (serverId: string, query?: AlbumArtistDetailQuery) => {
if (query) return [serverId, 'albumArtists', 'detail', query] as const;
return [serverId, 'albumArtists', 'detail'] as const;
},