Prevent sidebar re-render on every keypress (#152)

This commit is contained in:
Gregory Schier
2024-12-31 15:02:10 -08:00
committed by GitHub
parent 135c366e32
commit dfca17f9b7
32 changed files with 926 additions and 768 deletions

View File

@@ -1,5 +1,6 @@
import type { GrpcRequest, HttpRequest } from '@yaakapp-internal/models';
import { atom, useAtomValue } from 'jotai';
import {fallbackRequestName} from "../lib/fallbackRequestName";
import {jotaiStore} from "../lib/jotai";
import { activeRequestIdAtom } from './useActiveRequestId';
import { grpcRequestsAtom } from './useGrpcRequests';
@@ -20,6 +21,11 @@ export function getActiveRequest() {
return jotaiStore.get(activeRequestAtom);
}
export const activeRequestNameAtom = atom(get => {
const activeRequest = get(activeRequestAtom);
return fallbackRequestName(activeRequest);
});
export function useActiveRequest<T extends keyof TypeMap>(
model?: T | undefined,
): TypeMap[T] | null {