mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-31 22:43:11 +02:00
Create new workspace, and more optimizations
This commit is contained in:
@@ -8,9 +8,10 @@ import { matchPath } from 'react-router-dom';
|
||||
import { keyValueQueryKey } from '../hooks/useKeyValue';
|
||||
import { requestsQueryKey } from '../hooks/useRequests';
|
||||
import { responsesQueryKey } from '../hooks/useResponses';
|
||||
import { workspacesQueryKey } from '../hooks/useWorkspaces';
|
||||
import { DEFAULT_FONT_SIZE } from '../lib/constants';
|
||||
import { extractKeyValue } from '../lib/keyValueStore';
|
||||
import type { HttpRequest, HttpResponse, KeyValue } from '../lib/models';
|
||||
import type { HttpRequest, HttpResponse, KeyValue, Workspace } from '../lib/models';
|
||||
import { convertDates } from '../lib/models';
|
||||
import { AppRouter, WORKSPACE_REQUEST_PATH } from './AppRouter';
|
||||
|
||||
@@ -70,6 +71,25 @@ await listen('updated_response', ({ payload: response }: { payload: HttpResponse
|
||||
);
|
||||
});
|
||||
|
||||
await listen('updated_workspace', ({ payload: workspace }: { payload: Workspace }) => {
|
||||
queryClient.setQueryData(workspacesQueryKey(), (workspaces: Workspace[] = []) => {
|
||||
const newWorkspaces = [];
|
||||
let found = false;
|
||||
for (const w of workspaces) {
|
||||
if (w.id === workspace.id) {
|
||||
found = true;
|
||||
newWorkspaces.push(convertDates(workspace));
|
||||
} else {
|
||||
newWorkspaces.push(w);
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
newWorkspaces.push(convertDates(workspace));
|
||||
}
|
||||
return newWorkspaces;
|
||||
});
|
||||
});
|
||||
|
||||
await listen('send_request', async () => {
|
||||
const params = matchPath(WORKSPACE_REQUEST_PATH, window.location.pathname);
|
||||
const requestId = params?.params.requestId;
|
||||
|
||||
Reference in New Issue
Block a user