Merge remote-tracking branch 'origin/master'

This commit is contained in:
Gregory Schier
2024-07-28 15:40:37 -07:00
2 changed files with 8 additions and 8 deletions

View File

@@ -988,15 +988,14 @@ async fn cmd_save_response(
#[tauri::command]
async fn cmd_send_http_request(
window: WebviewWindow,
request_id: &str,
environment_id: Option<&str>,
cookie_jar_id: 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> {
let request = get_http_request(&window, request_id)
.await
.expect("Failed to get request");
let environment = match environment_id {
Some(id) => match get_environment(&window, id).await {
Ok(env) => Some(env),

View File

@@ -3,20 +3,21 @@ import { save } from '@tauri-apps/plugin-dialog';
import slugify from 'slugify';
import { trackEvent } from '../lib/analytics';
import type { HttpResponse } from '../lib/models';
import { getHttpRequest } from '../lib/store';
import { invokeCmd } from '../lib/tauri';
import { useActiveCookieJar } from './useActiveCookieJar';
import { useActiveEnvironment } from './useActiveEnvironment';
import { useAlert } from './useAlert';
import { useHttpRequests } from './useHttpRequests';
export function useSendAnyHttpRequest(options: { download?: boolean } = {}) {
const environment = useActiveEnvironment();
const alert = useAlert();
const { activeCookieJar } = useActiveCookieJar();
const requests = useHttpRequests();
return useMutation<HttpResponse | null, string, string | null>({
mutationKey: ['send_any_request'],
mutationFn: async (id) => {
const request = await getHttpRequest(id);
const request = requests.find((r) => r.id === id) ?? null;
if (request == null) {
return null;
}
@@ -33,7 +34,7 @@ export function useSendAnyHttpRequest(options: { download?: boolean } = {}) {
}
return invokeCmd('cmd_send_http_request', {
requestId: id,
request,
environmentId: environment?.id,
downloadDir: downloadDir,
cookieJarId: activeCookieJar?.id,