mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 10:03:33 +00:00
24 lines
944 B
TypeScript
24 lines
944 B
TypeScript
|
|
import { useCallback } from 'react';
|
||
|
|
import { useQuery } from '@tanstack/react-query';
|
||
|
|
import { queryKeys } from '/@/renderer/api/query-keys';
|
||
|
|
import type { AlbumArtistDetailQuery, RawAlbumArtistDetailResponse } from '/@/renderer/api/types';
|
||
|
|
import type { QueryOptions } from '/@/renderer/lib/react-query';
|
||
|
|
import { useCurrentServer } from '/@/renderer/store';
|
||
|
|
import { api } from '/@/renderer/api';
|
||
|
|
|
||
|
|
export const useAlbumArtistInfo = (query: AlbumArtistDetailQuery, options?: QueryOptions) => {
|
||
|
|
const server = useCurrentServer();
|
||
|
|
|
||
|
|
return useQuery({
|
||
|
|
enabled: !!server?.id && !!query.id,
|
||
|
|
queryFn: ({ signal }) => api.controller.getAlbumArtistDetail({ query, server, signal }),
|
||
|
|
queryKey: queryKeys.albumArtists.detail(server?.id || '', query),
|
||
|
|
select: useCallback(
|
||
|
|
(data: RawAlbumArtistDetailResponse | undefined) =>
|
||
|
|
api.normalize.albumArtistDetail(data, server),
|
||
|
|
[server],
|
||
|
|
),
|
||
|
|
...options,
|
||
|
|
});
|
||
|
|
};
|