mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-17 23:14:03 +01:00
Fix workspace deletion
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
import { useRoutes } from './useRoutes';
|
||||
import { workspacesQueryKey } from './useWorkspaces';
|
||||
@@ -18,7 +17,7 @@ export function useDeleteWorkspace(id: string | null) {
|
||||
if (id === null) return;
|
||||
await queryClient.invalidateQueries(workspacesQueryKey());
|
||||
if (id === activeWorkspaceId) {
|
||||
routes.navigate('workspace', { workspaceId: id });
|
||||
routes.navigate('workspaces');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
export type RouteParamsWorkspace = {
|
||||
workspaceId: string;
|
||||
};
|
||||
@@ -24,15 +26,18 @@ export const routePaths = {
|
||||
};
|
||||
|
||||
export function useRoutes() {
|
||||
const navigate = useNavigate();
|
||||
return {
|
||||
navigate<T extends keyof typeof routePaths>(
|
||||
path: T,
|
||||
params: Parameters<(typeof routePaths)[T]>[0],
|
||||
...params: Parameters<(typeof routePaths)[T]>
|
||||
) {
|
||||
// Not sure how to make TS work here, but it's good from the
|
||||
// outside caller perspective.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
routePaths[path](params as any);
|
||||
const resolvedPath = routePaths[path](...(params as any));
|
||||
console.log('NAVIGATE TO', resolvedPath, 'WITH PARAMS', params, 'AND PATH', path);
|
||||
navigate(resolvedPath);
|
||||
},
|
||||
paths: routePaths,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user