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