mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-23 01:49:13 +01:00
Start on plugin ctx API (#64)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useAppRoutes } from './useAppRoutes';
|
||||
import { getRecentCookieJars } from './useRecentCookieJars';
|
||||
import { getRecentEnvironments } from './useRecentEnvironments';
|
||||
import { getRecentRequests } from './useRecentRequests';
|
||||
|
||||
@@ -16,29 +17,21 @@ export function useOpenWorkspace() {
|
||||
workspaceId: string;
|
||||
inNewWindow: boolean;
|
||||
}) => {
|
||||
const environmentId = (await getRecentEnvironments(workspaceId))[0];
|
||||
const requestId = (await getRecentRequests(workspaceId))[0];
|
||||
const cookieJarId = (await getRecentCookieJars(workspaceId))[0];
|
||||
const baseArgs = { workspaceId, environmentId, cookieJarId } as const;
|
||||
if (inNewWindow) {
|
||||
const environmentId = (await getRecentEnvironments(workspaceId))[0];
|
||||
const requestId = (await getRecentRequests(workspaceId))[0];
|
||||
const path =
|
||||
requestId != null
|
||||
? routes.paths.request({
|
||||
workspaceId,
|
||||
environmentId,
|
||||
requestId,
|
||||
})
|
||||
: routes.paths.workspace({ workspaceId, environmentId });
|
||||
? routes.paths.request({ ...baseArgs, requestId })
|
||||
: routes.paths.workspace({ ...baseArgs });
|
||||
await invokeCmd('cmd_new_window', { url: path });
|
||||
} else {
|
||||
const environmentId = (await getRecentEnvironments(workspaceId))[0];
|
||||
const requestId = (await getRecentRequests(workspaceId))[0];
|
||||
if (requestId != null) {
|
||||
routes.navigate('request', {
|
||||
workspaceId: workspaceId,
|
||||
environmentId,
|
||||
requestId,
|
||||
});
|
||||
routes.navigate('request', { ...baseArgs, requestId });
|
||||
} else {
|
||||
routes.navigate('workspace', { workspaceId, environmentId });
|
||||
routes.navigate('workspace', { ...baseArgs });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user