mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 02:13:33 +00:00
Support genres in context menu
This commit is contained in:
parent
0b207c78e7
commit
d0aba6e16e
12 changed files with 182 additions and 56 deletions
|
|
@ -25,6 +25,7 @@ import {
|
|||
getAlbumSongsById,
|
||||
getAlbumArtistSongsById,
|
||||
getSongsByQuery,
|
||||
getGenreSongsById,
|
||||
} from '/@/renderer/features/player/utils';
|
||||
import { queryKeys } from '/@/renderer/api/query-keys';
|
||||
|
||||
|
|
@ -38,6 +39,9 @@ const getRootQueryKey = (itemType: LibraryItem, serverId: string) => {
|
|||
case LibraryItem.ALBUM_ARTIST:
|
||||
queryKey = queryKeys.songs.list(serverId);
|
||||
break;
|
||||
case LibraryItem.GENRE:
|
||||
queryKey = queryKeys.songs.list(serverId);
|
||||
break;
|
||||
case LibraryItem.PLAYLIST:
|
||||
queryKey = queryKeys.playlists.songList(serverId);
|
||||
break;
|
||||
|
|
@ -112,6 +116,8 @@ export const useHandlePlayQueueAdd = () => {
|
|||
queryClient,
|
||||
server,
|
||||
});
|
||||
} else if (itemType === LibraryItem.GENRE) {
|
||||
songList = await getGenreSongsById({ id, query, queryClient, server });
|
||||
} else if (itemType === LibraryItem.SONG) {
|
||||
if (id?.length === 1) {
|
||||
songList = await getSongById({ id: id?.[0], queryClient, server });
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {
|
|||
SongListSort,
|
||||
SortOrder,
|
||||
} from '/@/renderer/api/types';
|
||||
import { ServerListItem } from '/@/renderer/types';
|
||||
import { ServerListItem, ServerType } from '/@/renderer/types';
|
||||
|
||||
export const getPlaylistSongsById = async (args: {
|
||||
id: string;
|
||||
|
|
@ -86,6 +86,65 @@ export const getAlbumSongsById = async (args: {
|
|||
return res;
|
||||
};
|
||||
|
||||
export const getGenreSongsById = async (args: {
|
||||
id: string[];
|
||||
orderByIds?: boolean;
|
||||
query?: Partial<SongListQuery>;
|
||||
queryClient: QueryClient;
|
||||
server: ServerListItem | null;
|
||||
}) => {
|
||||
const { id, queryClient, server, query } = args;
|
||||
|
||||
const data: SongListResponse = {
|
||||
items: [],
|
||||
startIndex: 0,
|
||||
totalRecordCount: 0,
|
||||
};
|
||||
for (const genreId of id) {
|
||||
const queryFilter: SongListQuery = {
|
||||
_custom: {
|
||||
...(server?.type === ServerType.JELLYFIN && {
|
||||
jellyfin: {
|
||||
GenreIds: genreId,
|
||||
},
|
||||
}),
|
||||
...(server?.type === ServerType.NAVIDROME && {
|
||||
navidrome: {
|
||||
genre_id: genreId,
|
||||
},
|
||||
}),
|
||||
},
|
||||
sortBy: SongListSort.GENRE,
|
||||
sortOrder: SortOrder.ASC,
|
||||
startIndex: 0,
|
||||
...query,
|
||||
};
|
||||
|
||||
const queryKey = queryKeys.songs.list(server?.id, queryFilter);
|
||||
|
||||
const res = await queryClient.fetchQuery(
|
||||
queryKey,
|
||||
async ({ signal }) =>
|
||||
api.controller.getSongList({
|
||||
apiClientProps: {
|
||||
server,
|
||||
signal,
|
||||
},
|
||||
query: queryFilter,
|
||||
}),
|
||||
{
|
||||
cacheTime: 1000 * 60,
|
||||
staleTime: 1000 * 60,
|
||||
},
|
||||
);
|
||||
|
||||
data.items.push(...res!.items);
|
||||
data.totalRecordCount += res!.totalRecordCount;
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getAlbumArtistSongsById = async (args: {
|
||||
id: string[];
|
||||
orderByIds?: boolean;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue