mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 09:38:29 +02:00
Some fixes after upgrading react-query
This commit is contained in:
@@ -91,16 +91,19 @@ struct AppMetaData {
|
|||||||
version: String,
|
version: String,
|
||||||
name: String,
|
name: String,
|
||||||
app_data_dir: String,
|
app_data_dir: String,
|
||||||
|
app_log_dir: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn cmd_metadata(app_handle: AppHandle) -> Result<AppMetaData, ()> {
|
async fn cmd_metadata(app_handle: AppHandle) -> Result<AppMetaData, ()> {
|
||||||
let app_data_dir = app_handle.path().app_data_dir().unwrap();
|
let app_data_dir = app_handle.path().app_data_dir().unwrap();
|
||||||
|
let app_log_dir = app_handle.path().app_log_dir().unwrap();
|
||||||
return Ok(AppMetaData {
|
return Ok(AppMetaData {
|
||||||
is_dev: is_dev(),
|
is_dev: is_dev(),
|
||||||
version: app_handle.package_info().version.to_string(),
|
version: app_handle.package_info().version.to_string(),
|
||||||
name: app_handle.package_info().name.to_string(),
|
name: app_handle.package_info().name.to_string(),
|
||||||
app_data_dir: app_data_dir.to_string_lossy().to_string(),
|
app_data_dir: app_data_dir.to_string_lossy().to_string(),
|
||||||
|
app_log_dir: app_log_dir.to_string_lossy().to_string(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { HelmetProvider } from 'react-helmet-async';
|
|||||||
import { AppRouter } from './AppRouter';
|
import { AppRouter } from './AppRouter';
|
||||||
|
|
||||||
const queryClient = new QueryClient({
|
const queryClient = new QueryClient({
|
||||||
logger: undefined,
|
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
queries: {
|
queries: {
|
||||||
retry: false,
|
retry: false,
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ export function GrpcConnectionLayout({ style }: Props) {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
secondSlot={({ style }) =>
|
secondSlot={({ style }) =>
|
||||||
!grpc.go.isLoading && (
|
!grpc.go.isPending && (
|
||||||
<div
|
<div
|
||||||
style={style}
|
style={style}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export function GrpcProtoSelection({ requestId }: Props) {
|
|||||||
{!serverReflection && services != null && services.length > 0 && (
|
{!serverReflection && services != null && services.length > 0 && (
|
||||||
<Banner className="flex flex-col gap-2">
|
<Banner className="flex flex-col gap-2">
|
||||||
<p>
|
<p>
|
||||||
Found services
|
Found services{' '}
|
||||||
{services?.slice(0, 5).map((s, i) => {
|
{services?.slice(0, 5).map((s, i) => {
|
||||||
return (
|
return (
|
||||||
<span key={i}>
|
<span key={i}>
|
||||||
@@ -124,7 +124,6 @@ export function GrpcProtoSelection({ requestId }: Props) {
|
|||||||
className="ml-auto opacity-30 transition-opacity group-hover:opacity-100"
|
className="ml-auto opacity-30 transition-opacity group-hover:opacity-100"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
await protoFilesKv.set(protoFiles.filter((p) => p !== f));
|
await protoFilesKv.set(protoFiles.filter((p) => p !== f));
|
||||||
grpc.reflect.remove();
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export const SettingsDialog = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
title="Check for updates"
|
title="Check for updates"
|
||||||
icon="refresh"
|
icon="refresh"
|
||||||
spin={checkForUpdates.isLoading}
|
spin={checkForUpdates.isPending}
|
||||||
onClick={() => checkForUpdates.mutateAsync()}
|
onClick={() => checkForUpdates.mutateAsync()}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -135,6 +135,7 @@ export const SettingsDialog = () => {
|
|||||||
<KeyValueRows>
|
<KeyValueRows>
|
||||||
<KeyValueRow label="Version" value={appInfo.data?.version} />
|
<KeyValueRow label="Version" value={appInfo.data?.version} />
|
||||||
<KeyValueRow label="Data Directory" value={appInfo.data?.appDataDir} />
|
<KeyValueRow label="Data Directory" value={appInfo.data?.appDataDir} />
|
||||||
|
<KeyValueRow label="Logs Directory" value={appInfo.data?.appLogDir} />
|
||||||
</KeyValueRows>
|
</KeyValueRows>
|
||||||
</VStack>
|
</VStack>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { invoke } from '@tauri-apps/api/core';
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
|
|
||||||
|
export interface AppInfo {
|
||||||
|
isDev: boolean;
|
||||||
|
version: string;
|
||||||
|
name: string;
|
||||||
|
appDataDir: string;
|
||||||
|
appLogDir: string;
|
||||||
|
}
|
||||||
|
|
||||||
export function useAppInfo() {
|
export function useAppInfo() {
|
||||||
return useQuery(['appInfo'], async () => {
|
return useQuery({
|
||||||
return (await invoke('cmd_metadata')) as {
|
queryKey: ['appInfo'],
|
||||||
isDev: boolean;
|
queryFn: async () => {
|
||||||
version: string;
|
const metadata = await invoke('cmd_metadata');
|
||||||
name: string;
|
return metadata as AppInfo;
|
||||||
appDataDir: string;
|
},
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ export function useCreateFolder() {
|
|||||||
},
|
},
|
||||||
onSettled: () => trackEvent('folder', 'create'),
|
onSettled: () => trackEvent('folder', 'create'),
|
||||||
onSuccess: async (request) => {
|
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;
|
const { workspaceId } = folder;
|
||||||
|
|
||||||
// Nesting makes it hard to clean things up, so just clear everything that could have been deleted
|
// 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({ queryKey: httpRequestsQueryKey({ workspaceId }) });
|
||||||
await queryClient.invalidateQueries(foldersQueryKey({ 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
|
// Also clean up other things that may have been deleted
|
||||||
queryClient.setQueryData(httpRequestsQueryKey({ workspaceId }), []);
|
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 debouncedUrl = useDebouncedValue<string>(req?.url ?? 'n/a', 500);
|
||||||
const reflect = useQuery<ReflectResponseService[], string>({
|
const reflect = useQuery<ReflectResponseService[], string>({
|
||||||
enabled: req != null,
|
enabled: req != null,
|
||||||
queryKey: ['grpc_reflect', req?.id ?? 'n/a', debouncedUrl],
|
queryKey: ['grpc_reflect', req?.id ?? 'n/a', debouncedUrl, protoFiles],
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
return (await minPromiseMillis(
|
return (await minPromiseMillis(
|
||||||
|
|||||||
@@ -9,8 +9,12 @@ export function workspacesQueryKey(_?: {}) {
|
|||||||
|
|
||||||
export function useWorkspaces() {
|
export function useWorkspaces() {
|
||||||
return (
|
return (
|
||||||
useQuery(workspacesQueryKey(), async () => {
|
useQuery({
|
||||||
return (await invoke('cmd_list_workspaces')) as Workspace[];
|
queryKey: workspacesQueryKey(),
|
||||||
|
queryFn: async () => {
|
||||||
|
const workspaces = await invoke('cmd_list_workspaces');
|
||||||
|
return workspaces as Workspace[];
|
||||||
|
},
|
||||||
}).data ?? []
|
}).data ?? []
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { internalIpV4 } from 'internal-ip';
|
|||||||
import svgr from 'vite-plugin-svgr';
|
import svgr from 'vite-plugin-svgr';
|
||||||
import topLevelAwait from 'vite-plugin-top-level-await';
|
import topLevelAwait from 'vite-plugin-top-level-await';
|
||||||
|
|
||||||
const mobile = !!/android|ios/.exec(process.env.TAURI_ENV_PLATFORM);
|
const mobile = !!/android|ios/.exec(process.env.TAURI_ENV_PLATFORM ?? '');
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig(async () => ({
|
export default defineConfig(async () => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user