Skip to content

Commit

Permalink
Fix response filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
gschier committed Oct 21, 2024
1 parent 57c3a86 commit b9f397e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src-tauri/yaak_plugin_runtime/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,9 @@ impl PluginManager {
content_type: &str,
) -> Result<FilterResponse> {
let plugin_name = if content_type.to_lowercase().contains("json") {
"filter-jsonpath"
"@yaakapp/filter-jsonpath"
} else {
"filter-xpath"
"@yaakapp/filter-xpath"
};

let plugin = self
Expand Down
1 change: 1 addition & 0 deletions src-web/components/responseViewers/HTMLOrTextViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export function HTMLOrTextViewer({ response, pretty, textViewerClassName }: Prop
className={textViewerClassName}
onSaveResponse={saveResponse.mutate}
responseId={response.id}
requestId={response.requestId}
/>
);
}
Expand Down
12 changes: 7 additions & 5 deletions src-web/components/responseViewers/TextViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface Props {
text: string;
language: EditorProps['language'];
responseId: string;
requestId: string;
onSaveResponse: () => void;
}

Expand All @@ -37,20 +38,21 @@ export function TextViewer({
language,
text,
responseId,
requestId,
pretty,
className,
onSaveResponse,
}: Props) {
const [filterTextMap, setFilterTextMap] = useFilterText();
const [showLargeResponse, toggleShowLargeResponse] = useToggle();
const filterText = filterTextMap[responseId] ?? null;
const filterText = filterTextMap[requestId] ?? null;
const copy = useCopy();
const debouncedFilterText = useDebouncedValue(filterText, 200);
const setFilterText = useCallback(
(v: string | null) => {
setFilterTextMap((m) => ({ ...m, [responseId]: v }));
setFilterTextMap((m) => ({ ...m, [requestId]: v }));
},
[setFilterTextMap, responseId],
[setFilterTextMap, requestId],
);

const isSearching = filterText != null;
Expand All @@ -75,7 +77,7 @@ export function TextViewer({
nodes.push(
<div key="input" className="w-full !opacity-100">
<Input
key={responseId}
key={requestId}
validate={!filteredResponse.error}
hideLabel
autoFocus
Expand Down Expand Up @@ -110,7 +112,7 @@ export function TextViewer({
filteredResponse.error,
isSearching,
language,
responseId,
requestId,
setFilterText,
toggleSearch,
]);
Expand Down

0 comments on commit b9f397e

Please sign in to comment.