mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-17 06:00:20 +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 { SearchQuery } from '/@/shared/types/domain-types';
|
||||
|
||||
export const searchQueries = {
|
||||
@@ -11,11 +10,11 @@ export const searchQueries = {
|
||||
return queryOptions({
|
||||
queryFn: ({ signal }) => {
|
||||
return api.controller.search({
|
||||
apiClientProps: { server: getServerById(args.serverId), signal },
|
||||
apiClientProps: { serverId: args.serverId, signal },
|
||||
query: args.query,
|
||||
});
|
||||
},
|
||||
queryKey: queryKeys.search.list(args.serverId || '', args.query),
|
||||
queryKey: queryKeys.search.list(args.serverId, args.query),
|
||||
...args.options,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Command, CommandPalettePages } from '/@/renderer/features/search/compon
|
||||
import { ServerList } from '/@/renderer/features/servers/components/server-list';
|
||||
import { AppRoute } from '/@/renderer/router/routes';
|
||||
import { useAuthStoreActions, useServerList } from '/@/renderer/store';
|
||||
import { ServerListItem } from '/@/shared/types/domain-types';
|
||||
import { ServerListItemWithCredential } from '/@/shared/types/domain-types';
|
||||
|
||||
interface ServerCommandsProps {
|
||||
handleClose: () => void;
|
||||
@@ -32,7 +32,7 @@ export const ServerCommands = ({ handleClose, setPages, setQuery }: ServerComman
|
||||
}, [handleClose, setPages, setQuery, t]);
|
||||
|
||||
const handleSelectServer = useCallback(
|
||||
(server: ServerListItem) => {
|
||||
(server: ServerListItemWithCredential) => {
|
||||
navigate(AppRoute.HOME);
|
||||
setCurrentServer(server);
|
||||
handleClose();
|
||||
|
||||
Reference in New Issue
Block a user