mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-05-02 05:34:14 +02:00
Performance sweep (#147)
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useAppRoutes } from '../hooks/useAppRoutes';
|
||||
import { getRecentCookieJars } from '../hooks/useRecentCookieJars';
|
||||
import { getRecentEnvironments } from '../hooks/useRecentEnvironments';
|
||||
import { getRecentRequests } from '../hooks/useRecentRequests';
|
||||
import { useRecentWorkspaces } from '../hooks/useRecentWorkspaces';
|
||||
import { useWorkspaces } from '../hooks/useWorkspaces';
|
||||
import { router } from '../main';
|
||||
import { Route as WorkspaceRoute } from '../routes/workspaces/$workspaceId';
|
||||
import { Route as RequestRoute } from '../routes/workspaces/$workspaceId/requests/$requestId';
|
||||
|
||||
export function RedirectToLatestWorkspace() {
|
||||
const navigate = useNavigate();
|
||||
const routes = useAppRoutes();
|
||||
const workspaces = useWorkspaces();
|
||||
const recentWorkspaces = useRecentWorkspaces();
|
||||
|
||||
@@ -26,12 +25,20 @@ export function RedirectToLatestWorkspace() {
|
||||
const requestId = (await getRecentRequests(workspaceId))[0] ?? null;
|
||||
|
||||
if (workspaceId != null && requestId != null) {
|
||||
navigate(routes.paths.request({ workspaceId, environmentId, requestId, cookieJarId }));
|
||||
await router.navigate({
|
||||
to: RequestRoute.fullPath,
|
||||
params: { workspaceId, requestId },
|
||||
search: { cookieJarId, environmentId },
|
||||
});
|
||||
} else {
|
||||
navigate(routes.paths.workspace({ workspaceId, environmentId, cookieJarId }));
|
||||
await router.navigate({
|
||||
to: WorkspaceRoute.fullPath,
|
||||
params: { workspaceId },
|
||||
search: { cookieJarId, environmentId },
|
||||
});
|
||||
}
|
||||
})();
|
||||
}, [navigate, recentWorkspaces, routes.paths, workspaces, workspaces.length]);
|
||||
}, [recentWorkspaces, workspaces, workspaces.length]);
|
||||
|
||||
return <></>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user