mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import type { RQueryHookArgs } from '/@/renderer/lib/react-query';
|
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
|
import { api } from '/@/renderer/api';
|
|
import { queryKeys } from '/@/renderer/api/query-keys';
|
|
import { useServerById } from '/@/renderer/store';
|
|
import { AlbumListQuery } from '/@/shared/types/domain/album-domain-types';
|
|
|
|
export const useAlbumListCount = (args: RQueryHookArgs<AlbumListQuery>) => {
|
|
const { options, query, serverId } = args;
|
|
const server = useServerById(serverId);
|
|
|
|
return useQuery({
|
|
enabled: !!serverId,
|
|
queryFn: ({ signal }) => {
|
|
if (!server) throw new Error('Server not found');
|
|
return api.controller.getAlbumListCount({
|
|
apiClientProps: {
|
|
server,
|
|
signal,
|
|
},
|
|
query,
|
|
});
|
|
},
|
|
queryKey: queryKeys.albums.count(
|
|
serverId || '',
|
|
Object.keys(query).length === 0 ? undefined : query,
|
|
),
|
|
...options,
|
|
});
|
|
};
|