mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-24 02:11:10 +01:00
Some fixes after upgrading react-query
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
|
||||
export interface AppInfo {
|
||||
isDev: boolean;
|
||||
version: string;
|
||||
name: string;
|
||||
appDataDir: string;
|
||||
appLogDir: string;
|
||||
}
|
||||
|
||||
export function useAppInfo() {
|
||||
return useQuery(['appInfo'], async () => {
|
||||
return (await invoke('cmd_metadata')) as {
|
||||
isDev: boolean;
|
||||
version: string;
|
||||
name: string;
|
||||
appDataDir: string;
|
||||
};
|
||||
return useQuery({
|
||||
queryKey: ['appInfo'],
|
||||
queryFn: async () => {
|
||||
const metadata = await invoke('cmd_metadata');
|
||||
return metadata as AppInfo;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -35,7 +35,9 @@ export function useCreateFolder() {
|
||||
},
|
||||
onSettled: () => trackEvent('folder', 'create'),
|
||||
onSuccess: async (request) => {
|
||||
await queryClient.invalidateQueries(foldersQueryKey({ workspaceId: request.workspaceId }));
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: foldersQueryKey({ workspaceId: request.workspaceId }),
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ export function useDeleteFolder(id: string | null) {
|
||||
const { workspaceId } = folder;
|
||||
|
||||
// Nesting makes it hard to clean things up, so just clear everything that could have been deleted
|
||||
await queryClient.invalidateQueries(httpRequestsQueryKey({ workspaceId }));
|
||||
await queryClient.invalidateQueries(foldersQueryKey({ workspaceId }));
|
||||
await queryClient.invalidateQueries({ queryKey: httpRequestsQueryKey({ workspaceId }) });
|
||||
await queryClient.invalidateQueries({ queryKey: foldersQueryKey({ workspaceId }) });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ export function useDeleteWorkspace(workspace: Workspace | null) {
|
||||
|
||||
// Also clean up other things that may have been deleted
|
||||
queryClient.setQueryData(httpRequestsQueryKey({ workspaceId }), []);
|
||||
await queryClient.invalidateQueries(httpRequestsQueryKey({ workspaceId }));
|
||||
await queryClient.invalidateQueries({ queryKey: httpRequestsQueryKey({ workspaceId }) });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ export function useGrpc(
|
||||
const debouncedUrl = useDebouncedValue<string>(req?.url ?? 'n/a', 500);
|
||||
const reflect = useQuery<ReflectResponseService[], string>({
|
||||
enabled: req != null,
|
||||
queryKey: ['grpc_reflect', req?.id ?? 'n/a', debouncedUrl],
|
||||
queryKey: ['grpc_reflect', req?.id ?? 'n/a', debouncedUrl, protoFiles],
|
||||
refetchOnWindowFocus: false,
|
||||
queryFn: async () => {
|
||||
return (await minPromiseMillis(
|
||||
|
||||
@@ -9,8 +9,12 @@ export function workspacesQueryKey(_?: {}) {
|
||||
|
||||
export function useWorkspaces() {
|
||||
return (
|
||||
useQuery(workspacesQueryKey(), async () => {
|
||||
return (await invoke('cmd_list_workspaces')) as Workspace[];
|
||||
useQuery({
|
||||
queryKey: workspacesQueryKey(),
|
||||
queryFn: async () => {
|
||||
const workspaces = await invoke('cmd_list_workspaces');
|
||||
return workspaces as Workspace[];
|
||||
},
|
||||
}).data ?? []
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user