mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-07-07 13:25:18 +02:00
Improve response history menu (#492)
This commit is contained in:
@@ -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);
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user