feishin/src/renderer/features/artists/queries/album-artist-list-query.ts

24 lines
880 B
TypeScript
Raw Normal View History

2025-05-20 19:23:36 -07:00
import type { AlbumArtistListQuery } from '/@/shared/types/domain-types';
2022-12-30 21:04:06 -08:00
import { useQuery } from '@tanstack/react-query';
import { api } from '/@/renderer/api';
2022-12-30 21:04:06 -08:00
import { queryKeys } from '/@/renderer/api/query-keys';
2025-05-20 19:23:36 -07:00
import { QueryHookArgs } from '/@/renderer/lib/react-query';
2023-04-27 21:25:57 -07:00
import { getServerById } from '/@/renderer/store';
2022-12-30 21:04:06 -08:00
2023-04-27 21:25:57 -07:00
export const useAlbumArtistList = (args: QueryHookArgs<AlbumArtistListQuery>) => {
2023-07-01 19:10:05 -07:00
const { options, query, serverId } = args || {};
const server = getServerById(serverId);
2022-12-30 21:04:06 -08:00
2023-07-01 19:10:05 -07:00
return useQuery({
enabled: !!server?.id,
queryFn: ({ signal }) => {
if (!server) throw new Error('Server not found');
return api.controller.getAlbumArtistList({ apiClientProps: { server, signal }, query });
},
queryKey: queryKeys.albumArtists.list(server?.id || '', query),
...options,
});
2022-12-30 21:04:06 -08:00
};