mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-29 22:01:47 +02:00
Generalized frontend model store (#193)
This commit is contained in:
@@ -1,19 +1,7 @@
|
||||
import {listWebsocketConnections, listWebsocketRequests} from '@yaakapp-internal/ws';
|
||||
import { changeModelStoreWorkspace } from '@yaakapp-internal/models';
|
||||
import { useEffect } from 'react';
|
||||
import { jotaiStore } from '../lib/jotai';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { activeWorkspaceIdAtom, getActiveWorkspaceId } from './useActiveWorkspace';
|
||||
import { cookieJarsAtom } from './useCookieJars';
|
||||
import { environmentsAtom } from './useEnvironments';
|
||||
import { foldersAtom } from './useFolders';
|
||||
import { grpcConnectionsAtom } from './useGrpcConnections';
|
||||
import { grpcRequestsAtom } from './useGrpcRequests';
|
||||
import { httpRequestsAtom } from './useHttpRequests';
|
||||
import { httpResponsesAtom } from './useHttpResponses';
|
||||
import { keyValuesAtom } from './useKeyValue';
|
||||
import {websocketConnectionsAtom} from "./useWebsocketConnections";
|
||||
import { websocketRequestsAtom } from './useWebsocketRequests';
|
||||
import { workspaceMetaAtom } from './useWorkspaceMeta';
|
||||
import { activeWorkspaceIdAtom } from './useActiveWorkspace';
|
||||
|
||||
export function useSyncWorkspaceChildModels() {
|
||||
useEffect(() => {
|
||||
@@ -24,27 +12,6 @@ export function useSyncWorkspaceChildModels() {
|
||||
}
|
||||
|
||||
async function sync() {
|
||||
// Doesn't need a workspace ID, so sync it right away
|
||||
jotaiStore.set(keyValuesAtom, await invokeCmd('cmd_list_key_values'));
|
||||
|
||||
const workspaceId = getActiveWorkspaceId();
|
||||
if (workspaceId == null) return;
|
||||
|
||||
const args = { workspaceId };
|
||||
|
||||
// Set the things we need first, first
|
||||
jotaiStore.set(httpRequestsAtom, await invokeCmd('cmd_list_http_requests', args));
|
||||
jotaiStore.set(grpcRequestsAtom, await invokeCmd('cmd_list_grpc_requests', args));
|
||||
jotaiStore.set(foldersAtom, await invokeCmd('cmd_list_folders', args));
|
||||
jotaiStore.set(websocketRequestsAtom, await listWebsocketRequests(args));
|
||||
|
||||
// Then, set the rest
|
||||
jotaiStore.set(cookieJarsAtom, await invokeCmd('cmd_list_cookie_jars', args));
|
||||
jotaiStore.set(httpResponsesAtom, await invokeCmd('cmd_list_http_responses', args));
|
||||
jotaiStore.set(grpcConnectionsAtom, await invokeCmd('cmd_list_grpc_connections', args));
|
||||
jotaiStore.set(websocketConnectionsAtom, await listWebsocketConnections(args));
|
||||
jotaiStore.set(environmentsAtom, await invokeCmd('cmd_list_environments', args));
|
||||
|
||||
// Single models
|
||||
jotaiStore.set(workspaceMetaAtom, await invokeCmd('cmd_get_workspace_meta', { workspaceId }));
|
||||
const workspaceId = jotaiStore.get(activeWorkspaceIdAtom) ?? null;
|
||||
changeModelStoreWorkspace(workspaceId).catch(console.error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user