mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-31 14:33:18 +02:00
Fix performance related to having 100s of requests (#123)
This commit is contained in:
@@ -1,22 +1,8 @@
|
||||
import type { GrpcRequest } from '@yaakapp-internal/models';
|
||||
import { atom, useAtom } from 'jotai';
|
||||
import { useEffect } from 'react';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveWorkspace } from './useActiveWorkspace';
|
||||
import { atom, useAtomValue } from 'jotai';
|
||||
|
||||
export const grpcRequestsAtom = atom<GrpcRequest[]>([]);
|
||||
|
||||
export function useGrpcRequests() {
|
||||
const [items, setItems] = useAtom(grpcRequestsAtom);
|
||||
const workspace = useActiveWorkspace();
|
||||
|
||||
// Fetch new requests when workspace changes
|
||||
useEffect(() => {
|
||||
if (workspace == null) return;
|
||||
invokeCmd<GrpcRequest[]>('cmd_list_grpc_requests', { workspaceId: workspace.id }).then(
|
||||
setItems,
|
||||
);
|
||||
}, [setItems, workspace]);
|
||||
|
||||
return items;
|
||||
return useAtomValue(grpcRequestsAtom);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user