Improve response history menu (#492)

This commit is contained in:
Gregory Schier
2026-07-02 10:04:57 -07:00
committed by GitHub
parent 9b524e3dc7
commit 95ac3e310a
12 changed files with 351 additions and 75 deletions
@@ -3,10 +3,12 @@ import { copyToClipboard } from "../lib/copy";
import { getResponseBodyText } from "../lib/responseBody";
import { useFastMutation } from "./useFastMutation";
export function useCopyHttpResponse(response: HttpResponse) {
export function useCopyHttpResponse(response: HttpResponse | null) {
return useFastMutation({
mutationKey: ["copy_http_response", response.id],
mutationKey: ["copy_http_response", response?.id],
async mutationFn() {
if (response == null) return;
const body = await getResponseBodyText({ response, filter: null });
copyToClipboard(body);
},
+4 -2
View File
@@ -9,10 +9,12 @@ import { invokeCmd } from "../lib/tauri";
import { showToast } from "../lib/toast";
import { useFastMutation } from "./useFastMutation";
export function useSaveResponse(response: HttpResponse) {
export function useSaveResponse(response: HttpResponse | null) {
return useFastMutation({
mutationKey: ["save_response", response.id],
mutationKey: ["save_response", response?.id],
mutationFn: async () => {
if (response == null) return null;
const request = getModel("http_request", response.requestId);
if (request == null) return null;