mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-29 13:41:51 +02:00
Refactor commands and DB
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import useResizeObserver from '@react-hook/resize-observer';
|
||||
import classNames from 'classnames';
|
||||
import { format } from 'date-fns';
|
||||
import type { CSSProperties, FormEvent } from 'react';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import React, { useRef, useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useAlert } from '../hooks/useAlert';
|
||||
import type { GrpcMessage } from '../hooks/useGrpc';
|
||||
import { useGrpc } from '../hooks/useGrpc';
|
||||
@@ -129,6 +130,12 @@ export function GrpcConnectionLayout({ style }: Props) {
|
||||
return { value, options };
|
||||
}, [grpc.schema, method.value, service.value]);
|
||||
|
||||
const [paneSize, setPaneSize] = useState(99999);
|
||||
const urlContainerEl = useRef<HTMLDivElement>(null);
|
||||
useResizeObserver<HTMLDivElement>(urlContainerEl.current, (entry) => {
|
||||
setPaneSize(entry.contentRect.width);
|
||||
});
|
||||
|
||||
if (url.isLoading || url.value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -138,7 +145,13 @@ export function GrpcConnectionLayout({ style }: Props) {
|
||||
style={style}
|
||||
leftSlot={() => (
|
||||
<VStack space={2}>
|
||||
<div className="grid grid-cols-[minmax(0,1fr)_auto_auto] gap-1.5">
|
||||
<div
|
||||
ref={urlContainerEl}
|
||||
className={classNames(
|
||||
'grid grid-cols-[minmax(0,1fr)_auto_auto] gap-1.5',
|
||||
paneSize < 350 && '!grid-cols-1',
|
||||
)}
|
||||
>
|
||||
<UrlBar
|
||||
id="foo"
|
||||
url={url.value ?? ''}
|
||||
@@ -150,32 +163,34 @@ export function GrpcConnectionLayout({ style }: Props) {
|
||||
isLoading={grpc.unary.isLoading}
|
||||
onUrlChange={url.set}
|
||||
/>
|
||||
<Select
|
||||
hideLabel
|
||||
name="service"
|
||||
label="Service"
|
||||
className="text-gray-800"
|
||||
size="sm"
|
||||
value={select.value}
|
||||
onChange={handleChangeService}
|
||||
options={select.options}
|
||||
/>
|
||||
<IconButton
|
||||
className="border border-highlight"
|
||||
size="sm"
|
||||
title="ofo"
|
||||
hotkeyAction="request.send"
|
||||
onClick={handleConnect}
|
||||
icon={
|
||||
!activeMethod?.clientStreaming && activeMethod?.serverStreaming
|
||||
? 'arrowDownToDot'
|
||||
: activeMethod?.clientStreaming && !activeMethod?.serverStreaming
|
||||
? 'arrowUpFromDot'
|
||||
: activeMethod?.clientStreaming && activeMethod?.serverStreaming
|
||||
? 'arrowUpDown'
|
||||
: 'sendHorizontal'
|
||||
}
|
||||
/>
|
||||
<HStack space={1.5}>
|
||||
<Select
|
||||
hideLabel
|
||||
name="service"
|
||||
label="Service"
|
||||
className="text-gray-800"
|
||||
size="sm"
|
||||
value={select.value}
|
||||
onChange={handleChangeService}
|
||||
options={select.options}
|
||||
/>
|
||||
<IconButton
|
||||
className="border border-highlight"
|
||||
size="sm"
|
||||
title="ofo"
|
||||
hotkeyAction="request.send"
|
||||
onClick={handleConnect}
|
||||
icon={
|
||||
!activeMethod?.clientStreaming && activeMethod?.serverStreaming
|
||||
? 'arrowDownToDot'
|
||||
: activeMethod?.clientStreaming && !activeMethod?.serverStreaming
|
||||
? 'arrowUpFromDot'
|
||||
: activeMethod?.clientStreaming && activeMethod?.serverStreaming
|
||||
? 'arrowUpDown'
|
||||
: 'sendHorizontal'
|
||||
}
|
||||
/>
|
||||
</HStack>
|
||||
</div>
|
||||
<GrpcEditor
|
||||
forceUpdateKey={[service, method].join('::')}
|
||||
|
||||
@@ -102,7 +102,7 @@ export function SettingsDropdown() {
|
||||
label: 'Check for Updates',
|
||||
leftSlot: <Icon icon="update" />,
|
||||
onSelect: async () => {
|
||||
const hasUpdate: boolean = await invoke('check_for_updates');
|
||||
const hasUpdate: boolean = await invoke('cmd_check_for_updates');
|
||||
if (!hasUpdate) {
|
||||
alert({
|
||||
id: 'no-updates',
|
||||
|
||||
@@ -59,7 +59,7 @@ export const WorkspaceActionsDropdown = memo(function WorkspaceActionsDropdown({
|
||||
onClick={async () => {
|
||||
hide();
|
||||
const environmentId = (await getRecentEnvironments(w.id))[0];
|
||||
await invoke('new_window', {
|
||||
await invoke('cmd_new_window', {
|
||||
url: routes.paths.workspace({ workspaceId: w.id, environmentId }),
|
||||
});
|
||||
}}
|
||||
|
||||
@@ -6,6 +6,7 @@ const gapClasses = {
|
||||
0: 'gap-0',
|
||||
0.5: 'gap-0.5',
|
||||
1: 'gap-1',
|
||||
1.5: 'gap-1.5',
|
||||
2: 'gap-2',
|
||||
3: 'gap-3',
|
||||
4: 'gap-4',
|
||||
|
||||
@@ -15,7 +15,7 @@ export function useCookieJars() {
|
||||
queryKey: cookieJarsQueryKey({ workspaceId: workspaceId ?? 'n/a' }),
|
||||
queryFn: async () => {
|
||||
if (workspaceId == null) return [];
|
||||
return (await invoke('list_cookie_jars', { workspaceId })) as CookieJar[];
|
||||
return (await invoke('cmd_list_cookie_jars', { workspaceId })) as CookieJar[];
|
||||
},
|
||||
}).data ?? []
|
||||
);
|
||||
|
||||
@@ -23,7 +23,7 @@ export function useCreateCookieJar() {
|
||||
label: 'Name',
|
||||
defaultValue: 'My Jar',
|
||||
});
|
||||
return invoke('create_cookie_jar', { workspaceId, name });
|
||||
return invoke('cmd_create_cookie_jar', { workspaceId, name });
|
||||
},
|
||||
onSettled: () => trackEvent('CookieJar', 'Create'),
|
||||
onSuccess: async (cookieJar) => {
|
||||
|
||||
@@ -22,7 +22,7 @@ export function useCreateEnvironment() {
|
||||
label: 'Name',
|
||||
defaultValue: 'My Environment',
|
||||
});
|
||||
return invoke('create_environment', { name, variables: [], workspaceId });
|
||||
return invoke('cmd_create_environment', { name, variables: [], workspaceId });
|
||||
},
|
||||
onSettled: () => trackEvent('Environment', 'Create'),
|
||||
onSuccess: async (environment) => {
|
||||
|
||||
@@ -16,7 +16,7 @@ export function useCreateFolder() {
|
||||
}
|
||||
patch.name = patch.name || 'New Folder';
|
||||
patch.sortPriority = patch.sortPriority || -Date.now();
|
||||
return invoke('create_folder', { workspaceId, ...patch });
|
||||
return invoke('cmd_create_folder', { workspaceId, ...patch });
|
||||
},
|
||||
onSettled: () => trackEvent('Folder', 'Create'),
|
||||
onSuccess: async (request) => {
|
||||
|
||||
@@ -34,7 +34,7 @@ export function useCreateRequest() {
|
||||
}
|
||||
}
|
||||
patch.folderId = patch.folderId || activeRequest?.folderId;
|
||||
return invoke('create_request', { workspaceId, name: '', ...patch });
|
||||
return invoke('cmd_create_request', { workspaceId, name: '', ...patch });
|
||||
},
|
||||
onSettled: () => trackEvent('HttpRequest', 'Create'),
|
||||
onSuccess: async (request) => {
|
||||
|
||||
@@ -10,7 +10,7 @@ export function useCreateWorkspace({ navigateAfter }: { navigateAfter: boolean }
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<Workspace, unknown, Pick<Workspace, 'name'>>({
|
||||
mutationFn: (patch) => {
|
||||
return invoke('create_workspace', patch);
|
||||
return invoke('cmd_create_workspace', patch);
|
||||
},
|
||||
onSettled: () => trackEvent('Workspace', 'Create'),
|
||||
onSuccess: async (workspace) => {
|
||||
|
||||
@@ -27,7 +27,7 @@ export function useDeleteAnyRequest() {
|
||||
),
|
||||
});
|
||||
if (!confirmed) return null;
|
||||
return invoke('delete_request', { requestId: id });
|
||||
return invoke('cmd_delete_request', { requestId: id });
|
||||
},
|
||||
onSettled: () => trackEvent('HttpRequest', 'Delete'),
|
||||
onSuccess: async (request) => {
|
||||
|
||||
@@ -23,7 +23,7 @@ export function useDeleteCookieJar(cookieJar: CookieJar | null) {
|
||||
),
|
||||
});
|
||||
if (!confirmed) return null;
|
||||
return invoke('delete_cookie_jar', { cookieJarId: cookieJar?.id });
|
||||
return invoke('cmd_delete_cookie_jar', { cookieJarId: cookieJar?.id });
|
||||
},
|
||||
onSettled: () => trackEvent('CookieJar', 'Delete'),
|
||||
onSuccess: async (cookieJar) => {
|
||||
|
||||
@@ -23,7 +23,7 @@ export function useDeleteEnvironment(environment: Environment | null) {
|
||||
),
|
||||
});
|
||||
if (!confirmed) return null;
|
||||
return invoke('delete_environment', { environmentId: environment?.id });
|
||||
return invoke('cmd_delete_environment', { environmentId: environment?.id });
|
||||
},
|
||||
onSettled: () => trackEvent('Environment', 'Delete'),
|
||||
onSuccess: async (environment) => {
|
||||
|
||||
@@ -26,7 +26,7 @@ export function useDeleteFolder(id: string | null) {
|
||||
),
|
||||
});
|
||||
if (!confirmed) return null;
|
||||
return invoke('delete_folder', { folderId: id });
|
||||
return invoke('cmd_delete_folder', { folderId: id });
|
||||
},
|
||||
onSettled: () => trackEvent('Folder', 'Delete'),
|
||||
onSuccess: async (folder) => {
|
||||
|
||||
@@ -8,7 +8,7 @@ export function useDeleteResponse(id: string | null) {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<HttpResponse>({
|
||||
mutationFn: async () => {
|
||||
return await invoke('delete_response', { id: id });
|
||||
return await invoke('cmd_delete_response', { id: id });
|
||||
},
|
||||
onSettled: () => trackEvent('HttpResponse', 'Delete'),
|
||||
onSuccess: ({ requestId, id: responseId }) => {
|
||||
|
||||
@@ -8,7 +8,7 @@ export function useDeleteResponses(requestId?: string) {
|
||||
return useMutation({
|
||||
mutationFn: async () => {
|
||||
if (requestId === undefined) return;
|
||||
await invoke('delete_all_responses', { requestId });
|
||||
await invoke('cmd_delete_all_responses', { requestId });
|
||||
},
|
||||
onSettled: () => trackEvent('HttpResponse', 'DeleteMany'),
|
||||
onSuccess: async () => {
|
||||
|
||||
@@ -28,7 +28,7 @@ export function useDeleteWorkspace(workspace: Workspace | null) {
|
||||
),
|
||||
});
|
||||
if (!confirmed) return null;
|
||||
return invoke('delete_workspace', { workspaceId: workspace?.id });
|
||||
return invoke('cmd_delete_workspace', { workspaceId: workspace?.id });
|
||||
},
|
||||
onSettled: () => trackEvent('Workspace', 'Delete'),
|
||||
onSuccess: async (workspace) => {
|
||||
|
||||
@@ -21,7 +21,7 @@ export function useDuplicateRequest({
|
||||
return useMutation<HttpRequest, string>({
|
||||
mutationFn: async () => {
|
||||
if (id === null) throw new Error("Can't duplicate a null request");
|
||||
return invoke('duplicate_request', { id });
|
||||
return invoke('cmd_duplicate_request', { id });
|
||||
},
|
||||
onSettled: () => trackEvent('HttpRequest', 'Duplicate'),
|
||||
onSuccess: async (request) => {
|
||||
|
||||
@@ -15,7 +15,7 @@ export function useEnvironments() {
|
||||
queryKey: environmentsQueryKey({ workspaceId: workspaceId ?? 'n/a' }),
|
||||
queryFn: async () => {
|
||||
if (workspaceId == null) return [];
|
||||
return (await invoke('list_environments', { workspaceId })) as Environment[];
|
||||
return (await invoke('cmd_list_environments', { workspaceId })) as Environment[];
|
||||
},
|
||||
}).data ?? []
|
||||
);
|
||||
|
||||
@@ -25,7 +25,7 @@ export function useExportData() {
|
||||
return;
|
||||
}
|
||||
|
||||
await invoke('export_data', { workspaceId: workspace.id, exportPath });
|
||||
await invoke('cmd_export_data', { workspaceId: workspace.id, exportPath });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ export function useFilterResponse({
|
||||
return null;
|
||||
}
|
||||
|
||||
return (await invoke('filter_response', { responseId, filter })) as string | null;
|
||||
return (await invoke('cmd_filter_response', { responseId, filter })) as string | null;
|
||||
},
|
||||
}).data ?? null
|
||||
);
|
||||
|
||||
@@ -15,7 +15,7 @@ export function useFolders() {
|
||||
queryKey: foldersQueryKey({ workspaceId: workspaceId ?? 'n/a' }),
|
||||
queryFn: async () => {
|
||||
if (workspaceId == null) return [];
|
||||
return (await invoke('list_folders', { workspaceId })) as Folder[];
|
||||
return (await invoke('cmd_list_folders', { workspaceId })) as Folder[];
|
||||
},
|
||||
}).data ?? []
|
||||
);
|
||||
|
||||
@@ -30,7 +30,7 @@ export function useGrpc(url: string | null) {
|
||||
mutationKey: ['grpc_unary', url],
|
||||
mutationFn: async ({ service, method, message }) => {
|
||||
if (url === null) throw new Error('No URL provided');
|
||||
return (await invoke('grpc_call_unary', {
|
||||
return (await invoke('cmd_grpc_call_unary', {
|
||||
endpoint: url,
|
||||
service,
|
||||
method,
|
||||
@@ -50,7 +50,7 @@ export function useGrpc(url: string | null) {
|
||||
setMessages([
|
||||
{ isServer: false, message: JSON.stringify(JSON.parse(message)), time: new Date() },
|
||||
]);
|
||||
return (await invoke('grpc_server_streaming', {
|
||||
return (await invoke('cmd_grpc_server_streaming', {
|
||||
endpoint: url,
|
||||
service,
|
||||
method,
|
||||
@@ -64,7 +64,7 @@ export function useGrpc(url: string | null) {
|
||||
queryFn: async () => {
|
||||
if (url === null) return [];
|
||||
console.log('GETTING SCHEMA', url);
|
||||
return (await invoke('grpc_reflect', { endpoint: url })) as ReflectResponseService[];
|
||||
return (await invoke('cmd_grpc_reflect', { endpoint: url })) as ReflectResponseService[];
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ export function useImportData() {
|
||||
environments: Environment[];
|
||||
folders: Folder[];
|
||||
requests: HttpRequest[];
|
||||
} = await invoke('import_data', {
|
||||
} = await invoke('cmd_import_data', {
|
||||
filePaths: Array.isArray(selected) ? selected : [selected],
|
||||
});
|
||||
const importedWorkspace = imported.workspaces[0];
|
||||
|
||||
@@ -15,7 +15,7 @@ export function useRequests() {
|
||||
queryKey: requestsQueryKey({ workspaceId: workspaceId ?? 'n/a' }),
|
||||
queryFn: async () => {
|
||||
if (workspaceId == null) return [];
|
||||
return (await invoke('list_requests', { workspaceId })) as HttpRequest[];
|
||||
return (await invoke('cmd_list_requests', { workspaceId })) as HttpRequest[];
|
||||
},
|
||||
}).data ?? []
|
||||
);
|
||||
|
||||
@@ -13,7 +13,7 @@ export function useResponses(requestId: string | null) {
|
||||
initialData: [],
|
||||
queryKey: responsesQueryKey({ requestId: requestId ?? 'n/a' }),
|
||||
queryFn: async () => {
|
||||
return (await invoke('list_responses', { requestId, limit: 200 })) as HttpResponse[];
|
||||
return (await invoke('cmd_list_responses', { requestId, limit: 200 })) as HttpResponse[];
|
||||
},
|
||||
}).data ?? []
|
||||
);
|
||||
|
||||
@@ -31,7 +31,7 @@ export function useSendAnyRequest(options: { download?: boolean } = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
return invoke('send_request', {
|
||||
return invoke('cmd_send_request', {
|
||||
requestId: id,
|
||||
environmentId,
|
||||
downloadDir: downloadDir,
|
||||
|
||||
@@ -11,7 +11,7 @@ export function useSettings() {
|
||||
useQuery({
|
||||
queryKey: settingsQueryKey(),
|
||||
queryFn: async () => {
|
||||
return (await invoke('get_settings')) as Settings;
|
||||
return (await invoke('cmd_get_settings')) as Settings;
|
||||
},
|
||||
}).data ?? undefined
|
||||
);
|
||||
|
||||
@@ -14,7 +14,7 @@ export function useUpdateAnyFolder() {
|
||||
throw new Error("Can't update a null folder");
|
||||
}
|
||||
|
||||
await invoke('update_folder', { folder: update(folder) });
|
||||
await invoke('cmd_update_folder', { folder: update(folder) });
|
||||
},
|
||||
onMutate: async ({ id, update }) => {
|
||||
const folder = await getFolder(id);
|
||||
|
||||
@@ -20,7 +20,7 @@ export function useUpdateAnyRequest() {
|
||||
|
||||
const patchedRequest =
|
||||
typeof update === 'function' ? update(request) : { ...request, ...update };
|
||||
await invoke('update_request', { request: patchedRequest });
|
||||
await invoke('cmd_update_request', { request: patchedRequest });
|
||||
},
|
||||
onMutate: async ({ id, update }) => {
|
||||
const request = await getRequest(id);
|
||||
|
||||
@@ -15,7 +15,7 @@ export function useUpdateCookieJar(id: string | null) {
|
||||
|
||||
const newCookieJar = typeof v === 'function' ? v(cookieJar) : { ...cookieJar, ...v };
|
||||
console.log('NEW COOKIE JAR', newCookieJar.cookies.length);
|
||||
await invoke('update_cookie_jar', { cookieJar: newCookieJar });
|
||||
await invoke('cmd_update_cookie_jar', { cookieJar: newCookieJar });
|
||||
},
|
||||
onMutate: async (v) => {
|
||||
const cookieJar = await getCookieJar(id);
|
||||
|
||||
@@ -14,7 +14,7 @@ export function useUpdateEnvironment(id: string | null) {
|
||||
}
|
||||
|
||||
const newEnvironment = typeof v === 'function' ? v(environment) : { ...environment, ...v };
|
||||
await invoke('update_environment', { environment: newEnvironment });
|
||||
await invoke('cmd_update_environment', { environment: newEnvironment });
|
||||
},
|
||||
onMutate: async (v) => {
|
||||
const environment = await getEnvironment(id);
|
||||
|
||||
@@ -8,7 +8,7 @@ export function useUpdateSettings() {
|
||||
|
||||
return useMutation<void, unknown, Settings>({
|
||||
mutationFn: async (settings) => {
|
||||
await invoke('update_settings', { settings });
|
||||
await invoke('cmd_update_settings', { settings });
|
||||
},
|
||||
onMutate: async (settings) => {
|
||||
queryClient.setQueryData<Settings>(settingsQueryKey(), settings);
|
||||
|
||||
@@ -14,7 +14,7 @@ export function useUpdateWorkspace(id: string | null) {
|
||||
}
|
||||
|
||||
const newWorkspace = typeof v === 'function' ? v(workspace) : { ...workspace, ...v };
|
||||
await invoke('update_workspace', { workspace: newWorkspace });
|
||||
await invoke('cmd_update_workspace', { workspace: newWorkspace });
|
||||
},
|
||||
onMutate: async (v) => {
|
||||
const workspace = await getWorkspace(id);
|
||||
|
||||
@@ -11,7 +11,7 @@ export function useVariables({ environmentId }: { environmentId: string }) {
|
||||
useQuery({
|
||||
queryKey: variablesQueryKey({ environmentId }),
|
||||
queryFn: async () => {
|
||||
return (await invoke('list_variables', { environmentId })) as EnvironmentVariable[];
|
||||
return (await invoke('cmd_list_variables', { environmentId })) as EnvironmentVariable[];
|
||||
},
|
||||
}).data ?? []
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ export function workspacesQueryKey(_?: {}) {
|
||||
export function useWorkspaces() {
|
||||
return (
|
||||
useQuery(workspacesQueryKey(), async () => {
|
||||
return (await invoke('list_workspaces')) as Workspace[];
|
||||
return (await invoke('cmd_list_workspaces')) as Workspace[];
|
||||
}).data ?? []
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export function trackEvent(
|
||||
| 'Duplicate',
|
||||
attributes: Record<string, string | number> = {},
|
||||
) {
|
||||
invoke('track_event', {
|
||||
invoke('cmd_track_event', {
|
||||
resource: resource,
|
||||
action,
|
||||
attributes,
|
||||
|
||||
@@ -14,7 +14,7 @@ export async function setKeyValue<T>({
|
||||
key: string | string[];
|
||||
value: T;
|
||||
}): Promise<void> {
|
||||
await invoke('set_key_value', {
|
||||
await invoke('cmd_set_key_value', {
|
||||
namespace,
|
||||
key: buildKeyValueKey(key),
|
||||
value: JSON.stringify(value),
|
||||
@@ -30,7 +30,7 @@ export async function getKeyValue<T>({
|
||||
key: string | string[];
|
||||
fallback: T;
|
||||
}) {
|
||||
const kv = (await invoke('get_key_value', {
|
||||
const kv = (await invoke('cmd_get_key_value', {
|
||||
namespace,
|
||||
key: buildKeyValueKey(key),
|
||||
})) as KeyValue | null;
|
||||
|
||||
@@ -7,5 +7,5 @@ export async function sendEphemeralRequest(
|
||||
): Promise<HttpResponse> {
|
||||
// Remove some things that we don't want to associate
|
||||
const newRequest = { ...request };
|
||||
return invoke('send_ephemeral_request', { request: newRequest, environmentId });
|
||||
return invoke('cmd_send_ephemeral_request', { request: newRequest, environmentId });
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ import { invoke } from '@tauri-apps/api';
|
||||
import type { CookieJar, Environment, Folder, HttpRequest, Settings, Workspace } from './models';
|
||||
|
||||
export async function getSettings(): Promise<Settings> {
|
||||
return invoke('get_settings', {});
|
||||
return invoke('cmd_get_settings', {});
|
||||
}
|
||||
|
||||
export async function getRequest(id: string | null): Promise<HttpRequest | null> {
|
||||
if (id === null) return null;
|
||||
const request: HttpRequest = (await invoke('get_request', { id })) ?? null;
|
||||
const request: HttpRequest = (await invoke('cmd_get_request', { id })) ?? null;
|
||||
if (request == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ export async function getRequest(id: string | null): Promise<HttpRequest | null>
|
||||
|
||||
export async function getEnvironment(id: string | null): Promise<Environment | null> {
|
||||
if (id === null) return null;
|
||||
const environment: Environment = (await invoke('get_environment', { id })) ?? null;
|
||||
const environment: Environment = (await invoke('cmd_get_environment', { id })) ?? null;
|
||||
if (environment == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ export async function getEnvironment(id: string | null): Promise<Environment | n
|
||||
|
||||
export async function getFolder(id: string | null): Promise<Folder | null> {
|
||||
if (id === null) return null;
|
||||
const folder: Folder = (await invoke('get_folder', { id })) ?? null;
|
||||
const folder: Folder = (await invoke('cmd_get_folder', { id })) ?? null;
|
||||
if (folder == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -34,7 +34,7 @@ export async function getFolder(id: string | null): Promise<Folder | null> {
|
||||
|
||||
export async function getWorkspace(id: string | null): Promise<Workspace | null> {
|
||||
if (id === null) return null;
|
||||
const workspace: Workspace = (await invoke('get_workspace', { id })) ?? null;
|
||||
const workspace: Workspace = (await invoke('cmd_get_workspace', { id })) ?? null;
|
||||
if (workspace == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ export async function getWorkspace(id: string | null): Promise<Workspace | null>
|
||||
|
||||
export async function getCookieJar(id: string | null): Promise<CookieJar | null> {
|
||||
if (id === null) return null;
|
||||
const cookieJar: CookieJar = (await invoke('get_cookie_jar', { id })) ?? null;
|
||||
const cookieJar: CookieJar = (await invoke('cmd_get_cookie_jar', { id })) ?? null;
|
||||
if (cookieJar == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import { type } from '@tauri-apps/api/os';
|
||||
import { appWindow } from '@tauri-apps/api/window';
|
||||
import { StrictMode } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { attachConsole } from 'tauri-plugin-log-api';
|
||||
import { App } from './components/App';
|
||||
import { maybeRestorePathname } from './lib/persistPathname';
|
||||
import './main.css';
|
||||
import { getSettings } from './lib/store';
|
||||
import type { Appearance } from './lib/theme/window';
|
||||
import { setAppearanceOnDocument } from './lib/theme/window';
|
||||
import { appWindow } from '@tauri-apps/api/window';
|
||||
import { type } from '@tauri-apps/api/os';
|
||||
|
||||
// Hide decorations here because it doesn't work in Rust for some reason (bug?)
|
||||
const osType = await type();
|
||||
@@ -17,8 +14,8 @@ if (osType !== 'Darwin') {
|
||||
await appWindow.setDecorations(false);
|
||||
}
|
||||
|
||||
await attachConsole();
|
||||
await maybeRestorePathname();
|
||||
// await attachConsole();
|
||||
// await maybeRestorePathname();
|
||||
|
||||
const settings = await getSettings();
|
||||
setAppearanceOnDocument(settings.appearance as Appearance);
|
||||
|
||||
Reference in New Issue
Block a user