2025-05-20 19:23:36 -07:00
|
|
|
import type { AlbumArtistDetailQuery } from '/@/shared/types/domain-types';
|
2025-05-18 14:03:18 -07:00
|
|
|
|
2023-01-12 18:43:25 -08:00
|
|
|
import { useQuery } from '@tanstack/react-query';
|
2025-05-18 14:03:18 -07:00
|
|
|
|
|
|
|
|
import { api } from '/@/renderer/api';
|
2023-01-12 18:43:25 -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';
|
2023-01-12 18:43:25 -08:00
|
|
|
|
2023-04-27 21:25:57 -07:00
|
|
|
export const useAlbumArtistInfo = (args: QueryHookArgs<AlbumArtistDetailQuery>) => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const { options, query, serverId } = args || {};
|
|
|
|
|
const server = getServerById(serverId);
|
2023-01-12 18:43:25 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
return useQuery({
|
|
|
|
|
enabled: !!server?.id && !!query.id,
|
|
|
|
|
queryFn: ({ signal }) => {
|
|
|
|
|
if (!server) throw new Error('Server not found');
|
|
|
|
|
return api.controller.getAlbumArtistDetail({
|
|
|
|
|
apiClientProps: { server, signal },
|
|
|
|
|
query,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
queryKey: queryKeys.albumArtists.detail(server?.id || '', query),
|
|
|
|
|
...options,
|
|
|
|
|
});
|
2023-01-12 18:43:25 -08:00
|
|
|
};
|