diff --git a/apps/yaak-client/components/responseViewers/HTMLOrTextViewer.tsx b/apps/yaak-client/components/responseViewers/HTMLOrTextViewer.tsx index 9999d1e3..b081fbae 100644 --- a/apps/yaak-client/components/responseViewers/HTMLOrTextViewer.tsx +++ b/apps/yaak-client/components/responseViewers/HTMLOrTextViewer.tsx @@ -69,6 +69,7 @@ function HttpTextViewer({ response, text, language, pretty, className }: HttpTex text={text} language={language} stateKey={`response.body.${response.id}`} + filterStateKey={`response.body.${response.requestId}`} pretty={pretty} className={className} onFilter={filterCallback} diff --git a/apps/yaak-client/components/responseViewers/TextViewer.tsx b/apps/yaak-client/components/responseViewers/TextViewer.tsx index c70500d2..ffd56185 100644 --- a/apps/yaak-client/components/responseViewers/TextViewer.tsx +++ b/apps/yaak-client/components/responseViewers/TextViewer.tsx @@ -16,6 +16,7 @@ interface Props { text: string; language: EditorProps["language"]; stateKey: string | null; + filterStateKey?: string | null; pretty?: boolean; className?: string; onFilter?: (filter: string) => { @@ -27,16 +28,25 @@ interface Props { const useFilterText = createGlobalState>({}); -export function TextViewer({ language, text, stateKey, pretty, className, onFilter }: Props) { +export function TextViewer({ + language, + text, + stateKey, + filterStateKey, + pretty, + className, + onFilter, +}: Props) { + const filterKey = filterStateKey ?? stateKey; const [filterTextMap, setFilterTextMap] = useFilterText(); - const filterText = stateKey ? (filterTextMap[stateKey] ?? null) : null; + const filterText = filterKey ? (filterTextMap[filterKey] ?? null) : null; const debouncedFilterText = useDebouncedValue(filterText); const setFilterText = useCallback( (v: string | null) => { - if (!stateKey) return; - setFilterTextMap((m) => ({ ...m, [stateKey]: v })); + if (!filterKey) return; + setFilterTextMap((m) => ({ ...m, [filterKey]: v })); }, - [setFilterTextMap, stateKey], + [filterKey, setFilterTextMap], ); const isSearching = filterText != null; @@ -64,7 +74,7 @@ export function TextViewer({ language, text, stateKey, pretty, className, onFilt nodes.push(
e.key === "Escape" && toggleSearch()} onChange={setFilterText} - stateKey={stateKey ? `filter.${stateKey}` : null} + stateKey={filterKey ? `filter.${filterKey}` : null} />
, ); @@ -97,12 +107,12 @@ export function TextViewer({ language, text, stateKey, pretty, className, onFilt return nodes; }, [ canFilter, + filterKey, filterText, filteredResponse.error, filteredResponse.isPending, isSearching, language, - stateKey, setFilterText, toggleSearch, ]);