mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-18 07:24:07 +01:00
Slight refactor to copy-as-curl
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { writeText } from '@tauri-apps/plugin-clipboard-manager';
|
||||
import { useState } from 'react';
|
||||
|
||||
export function useCopyAsCurl(requestId: string) {
|
||||
return useMutation<string>({
|
||||
mutationFn: async () => {
|
||||
const [checked, setChecked] = useState<boolean>(false);
|
||||
return [
|
||||
checked,
|
||||
async () => {
|
||||
const cmd: string = await invoke('cmd_request_to_curl', { requestId });
|
||||
await writeText(cmd);
|
||||
setChecked(true);
|
||||
setTimeout(() => setChecked(false), 800);
|
||||
return cmd;
|
||||
},
|
||||
});
|
||||
] as const;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user