Add song detail controller

This commit is contained in:
jeffvli 2023-05-19 22:20:32 -07:00 committed by Jeff
parent 2cefc092ce
commit c4fb9a2e72
4 changed files with 37 additions and 3 deletions

View file

@ -256,6 +256,15 @@ const getSongList = async (args: SongListArgs) => {
)?.(args);
};
const getSongDetail = async (args: SongDetailArgs) => {
return (
apiController(
'getSongDetail',
args.apiClientProps.server?.type,
) as ControllerEndpoint['getSongDetail']
)?.(args);
};
const getMusicFolderList = async (args: MusicFolderListArgs) => {
return (
apiController(
@ -444,6 +453,7 @@ export const controller = {
getPlaylistDetail,
getPlaylistList,
getPlaylistSongList,
getSongDetail,
getSongList,
getTopSongList,
getUserList,

View file

@ -11,6 +11,7 @@ import type {
AlbumArtistDetailQuery,
TopSongListQuery,
SearchQuery,
SongDetailQuery,
} from './types';
export const queryKeys = {
@ -88,6 +89,10 @@ export const queryKeys = {
root: (serverId: string) => [serverId] as const,
},
songs: {
detail: (serverId: string, query?: SongDetailQuery) => {
if (query) return [serverId, 'songs', 'detail', query] as const;
return [serverId, 'songs', 'detail'] as const;
},
list: (serverId: string, query?: SongListQuery) => {
if (query) return [serverId, 'songs', 'list', query] as const;
return [serverId, 'songs', 'list'] as const;

View file

@ -310,8 +310,6 @@ const scrobble = async (args: ScrobbleArgs): Promise<ScrobbleResponse> => {
const search3 = async (args: SearchArgs): Promise<SearchResponse> => {
const { query, apiClientProps } = args;
console.log('search api');
const res = await ssApiClient(apiClientProps).search3({
query: {
albumCount: query.albumLimit,

View file

@ -167,7 +167,7 @@ export type Album = {
} & { songs?: Song[] };
export type Song = {
album: string;
album: string | undefined;
albumArtists: RelatedArtist[];
albumId: string;
artistName: string;
@ -971,6 +971,27 @@ export type SearchQuery = {
songStartIndex?: number;
};
export type SearchSongsQuery = {
musicFolderId?: string;
query?: string;
songLimit?: number;
songStartIndex?: number;
};
export type SearchAlbumsQuery = {
albumLimit?: number;
albumStartIndex?: number;
musicFolderId?: string;
query?: string;
};
export type SearchAlbumArtistsQuery = {
albumArtistLimit?: number;
albumArtistStartIndex?: number;
musicFolderId?: string;
query?: string;
};
export type SearchArgs = {
query: SearchQuery;
} & BaseEndpointArgs;