Fix performance related to having 100s of requests (#123)

This commit is contained in:
Gregory Schier
2024-10-08 15:16:57 -06:00
committed by GitHub
parent 4b7712df80
commit c7eccddac9
34 changed files with 456 additions and 423 deletions

View File

@@ -3,10 +3,15 @@ import type { HttpRequest } from '@yaakapp-internal/models';
import type {
CallHttpRequestActionRequest,
GetHttpRequestActionsResponse,
HttpRequestAction,
} from '@yaakapp-internal/plugin';
import { invokeCmd } from '../lib/tauri';
import { usePluginsKey } from './usePlugins';
export type CallableHttpRequestAction = Pick<HttpRequestAction, 'key' | 'label' | 'icon'> & {
call: (httpRequest: HttpRequest) => Promise<void>;
};
export function useHttpRequestActions() {
const pluginsKey = usePluginsKey();
@@ -20,7 +25,7 @@ export function useHttpRequestActions() {
},
});
return (
const actions: CallableHttpRequestAction[] =
httpRequestActions.data?.flatMap((r) =>
r.actions.map((a) => ({
key: a.key,
@@ -35,6 +40,7 @@ export function useHttpRequestActions() {
await invokeCmd('cmd_call_http_request_action', { req: payload });
},
})),
) ?? []
);
) ?? [];
return actions;
}