mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-22 08:38:29 +02:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -988,15 +988,14 @@ async fn cmd_save_response(
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn cmd_send_http_request(
|
async fn cmd_send_http_request(
|
||||||
window: WebviewWindow,
|
window: WebviewWindow,
|
||||||
request_id: &str,
|
|
||||||
environment_id: Option<&str>,
|
environment_id: Option<&str>,
|
||||||
cookie_jar_id: Option<&str>,
|
cookie_jar_id: Option<&str>,
|
||||||
download_dir: Option<&str>,
|
download_dir: Option<&str>,
|
||||||
|
// NOTE: We receive the entire request because to account for the race
|
||||||
|
// condition where the user may have just edited a field before sending
|
||||||
|
// that has not yet been saved in the DB.
|
||||||
|
request: HttpRequest,
|
||||||
) -> Result<HttpResponse, String> {
|
) -> Result<HttpResponse, String> {
|
||||||
let request = get_http_request(&window, request_id)
|
|
||||||
.await
|
|
||||||
.expect("Failed to get request");
|
|
||||||
|
|
||||||
let environment = match environment_id {
|
let environment = match environment_id {
|
||||||
Some(id) => match get_environment(&window, id).await {
|
Some(id) => match get_environment(&window, id).await {
|
||||||
Ok(env) => Some(env),
|
Ok(env) => Some(env),
|
||||||
|
|||||||
@@ -3,20 +3,21 @@ import { save } from '@tauri-apps/plugin-dialog';
|
|||||||
import slugify from 'slugify';
|
import slugify from 'slugify';
|
||||||
import { trackEvent } from '../lib/analytics';
|
import { trackEvent } from '../lib/analytics';
|
||||||
import type { HttpResponse } from '../lib/models';
|
import type { HttpResponse } from '../lib/models';
|
||||||
import { getHttpRequest } from '../lib/store';
|
|
||||||
import { invokeCmd } from '../lib/tauri';
|
import { invokeCmd } from '../lib/tauri';
|
||||||
import { useActiveCookieJar } from './useActiveCookieJar';
|
import { useActiveCookieJar } from './useActiveCookieJar';
|
||||||
import { useActiveEnvironment } from './useActiveEnvironment';
|
import { useActiveEnvironment } from './useActiveEnvironment';
|
||||||
import { useAlert } from './useAlert';
|
import { useAlert } from './useAlert';
|
||||||
|
import { useHttpRequests } from './useHttpRequests';
|
||||||
|
|
||||||
export function useSendAnyHttpRequest(options: { download?: boolean } = {}) {
|
export function useSendAnyHttpRequest(options: { download?: boolean } = {}) {
|
||||||
const environment = useActiveEnvironment();
|
const environment = useActiveEnvironment();
|
||||||
const alert = useAlert();
|
const alert = useAlert();
|
||||||
const { activeCookieJar } = useActiveCookieJar();
|
const { activeCookieJar } = useActiveCookieJar();
|
||||||
|
const requests = useHttpRequests();
|
||||||
return useMutation<HttpResponse | null, string, string | null>({
|
return useMutation<HttpResponse | null, string, string | null>({
|
||||||
mutationKey: ['send_any_request'],
|
mutationKey: ['send_any_request'],
|
||||||
mutationFn: async (id) => {
|
mutationFn: async (id) => {
|
||||||
const request = await getHttpRequest(id);
|
const request = requests.find((r) => r.id === id) ?? null;
|
||||||
if (request == null) {
|
if (request == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -33,7 +34,7 @@ export function useSendAnyHttpRequest(options: { download?: boolean } = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return invokeCmd('cmd_send_http_request', {
|
return invokeCmd('cmd_send_http_request', {
|
||||||
requestId: id,
|
request,
|
||||||
environmentId: environment?.id,
|
environmentId: environment?.id,
|
||||||
downloadDir: downloadDir,
|
downloadDir: downloadDir,
|
||||||
cookieJarId: activeCookieJar?.id,
|
cookieJarId: activeCookieJar?.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user