mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-14 20:40:21 +02:00
refactor api controller to internalize server fetch
This commit is contained in:
@@ -3,7 +3,6 @@ import { queryOptions } from '@tanstack/react-query';
|
||||
import { api } from '/@/renderer/api';
|
||||
import { queryKeys } from '/@/renderer/api/query-keys';
|
||||
import { QueryHookArgs } from '/@/renderer/lib/react-query';
|
||||
import { getServerById } from '/@/renderer/store';
|
||||
import { AlbumListQuery, AlbumListSort, SortOrder } from '/@/shared/types/domain-types';
|
||||
|
||||
export const homeQueries = {
|
||||
@@ -18,14 +17,12 @@ export const homeQueries = {
|
||||
|
||||
return queryOptions({
|
||||
queryFn: ({ signal }) => {
|
||||
const server = getServerById(args.serverId);
|
||||
if (!server) throw new Error('Server not found');
|
||||
return api.controller.getAlbumList({
|
||||
apiClientProps: { server, signal },
|
||||
apiClientProps: { serverId: args.serverId, signal },
|
||||
query: requestQuery,
|
||||
});
|
||||
},
|
||||
queryKey: queryKeys.albums.list(args.serverId || '', requestQuery),
|
||||
queryKey: queryKeys.albums.list(args.serverId, requestQuery),
|
||||
...args.options,
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user