mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-24 10:21:15 +01:00
Workspace dropdown to RadioDropdown
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import type { Workspace } from '../lib/models';
|
||||
import { useAppRoutes } from './useAppRoutes';
|
||||
import { getRecentEnvironments } from './useRecentEnvironments';
|
||||
import { getRecentRequests } from './useRecentRequests';
|
||||
@@ -10,37 +9,35 @@ export function useOpenWorkspace() {
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({
|
||||
workspace,
|
||||
workspaceId,
|
||||
inNewWindow,
|
||||
}: {
|
||||
workspace: Workspace;
|
||||
workspaceId: string;
|
||||
inNewWindow: boolean;
|
||||
}) => {
|
||||
if (workspace == null) return;
|
||||
|
||||
if (inNewWindow) {
|
||||
const environmentId = (await getRecentEnvironments(workspace.id))[0];
|
||||
const requestId = (await getRecentRequests(workspace.id))[0];
|
||||
const environmentId = (await getRecentEnvironments(workspaceId))[0];
|
||||
const requestId = (await getRecentRequests(workspaceId))[0];
|
||||
const path =
|
||||
requestId != null
|
||||
? routes.paths.request({
|
||||
workspaceId: workspace.id,
|
||||
workspaceId,
|
||||
environmentId,
|
||||
requestId,
|
||||
})
|
||||
: routes.paths.workspace({ workspaceId: workspace.id, environmentId });
|
||||
: routes.paths.workspace({ workspaceId, environmentId });
|
||||
await invoke('cmd_new_window', { url: path });
|
||||
} else {
|
||||
const environmentId = (await getRecentEnvironments(workspace.id))[0];
|
||||
const requestId = (await getRecentRequests(workspace.id))[0];
|
||||
const environmentId = (await getRecentEnvironments(workspaceId))[0];
|
||||
const requestId = (await getRecentRequests(workspaceId))[0];
|
||||
if (requestId != null) {
|
||||
routes.navigate('request', {
|
||||
workspaceId: workspace.id,
|
||||
workspaceId: workspaceId,
|
||||
environmentId,
|
||||
requestId,
|
||||
});
|
||||
} else {
|
||||
routes.navigate('workspace', { workspaceId: workspace.id, environmentId });
|
||||
routes.navigate('workspace', { workspaceId, environmentId });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user