Fix lint errors

This commit is contained in:
Gregory Schier
2025-12-28 15:18:01 -08:00
parent 8e1959b7c3
commit 2fc8678183
7 changed files with 33 additions and 24 deletions

View File

@@ -12,7 +12,7 @@ export type HttpRequest = { model: "http_request", id: string, createdAt: string
export type HttpRequestHeader = { enabled?: boolean, name: string, value: string, id?: string, };
export type HttpResponse = { model: "http_response", id: string, createdAt: string, updatedAt: string, workspaceId: string, requestId: string, bodyPath: string | null, contentLength: bigint | null, contentLengthCompressed: bigint | null, elapsed: number, elapsedHeaders: number, error: string | null, headers: Array<HttpResponseHeader>, remoteAddr: string | null, requestContentLength: bigint | null, requestHeaders: Array<HttpResponseHeader>, status: number, statusReason: string | null, state: HttpResponseState, url: string, version: string | null, };
export type HttpResponse = { model: "http_response", id: string, createdAt: string, updatedAt: string, workspaceId: string, requestId: string, bodyPath: string | null, contentLength: number | null, contentLengthCompressed: number | null, elapsed: number, elapsedHeaders: number, error: string | null, headers: Array<HttpResponseHeader>, remoteAddr: string | null, requestContentLength: number | null, requestHeaders: Array<HttpResponseHeader>, status: number, statusReason: string | null, state: HttpResponseState, url: string, version: string | null, };
export type HttpResponseHeader = { name: string, value: string, };

View File

@@ -356,7 +356,7 @@ async fn execute_transaction<R: Runtime>(
})?;
// Create bounded channel for receiving events and spawn a task to store them in DB
// Buffer size of 100 events provides backpressure if DB writes are slow
// Buffer size of 100 events provides back pressure if DB writes are slow
let (event_tx, mut event_rx) =
tokio::sync::mpsc::channel::<yaak_http::sender::HttpResponseEvent>(100);
@@ -466,7 +466,7 @@ async fn execute_transaction<R: Runtime>(
.iter()
.map(|(name, value)| HttpResponseHeader { name: name.clone(), value: value.clone() })
.collect();
r.content_length = http_response.content_length.map(|l| l as i64);
r.content_length = http_response.content_length.map(|l| l as i32);
r.state = HttpResponseState::Connected;
r.request_headers = http_response
.request_headers
@@ -528,7 +528,7 @@ async fn execute_transaction<R: Runtime>(
if elapsed_since_update >= UPDATE_INTERVAL_MS {
response_ctx.update(|r| {
r.elapsed = start.elapsed().as_millis() as i32;
r.content_length = Some(written_bytes as i64);
r.content_length = Some(written_bytes as i32);
})?;
last_update_time = now;
}
@@ -542,7 +542,7 @@ async fn execute_transaction<R: Runtime>(
// Final update with closed state and accurate byte count
response_ctx.update(|r| {
r.elapsed = start.elapsed().as_millis() as i32;
r.content_length = Some(written_bytes as i64);
r.content_length = Some(written_bytes as i32);
r.state = HttpResponseState::Closed;
})?;
@@ -572,7 +572,7 @@ fn write_bytes_to_db_sync<R: Runtime>(
// Update the response with the total request body size
response_ctx.update(|r| {
r.request_content_length = Some(data.len() as i64);
r.request_content_length = Some(data.len() as i32);
})?;
Ok(())
@@ -634,7 +634,7 @@ async fn write_stream_chunks_to_db<R: Runtime>(
app_handle.with_tx(|tx| {
debug!("Updating final body length {total_bytes}");
if let Ok(mut response) = tx.get_http_response(&response_id) {
response.request_content_length = Some(total_bytes as i64);
response.request_content_length = Some(total_bytes as i32);
tx.update_http_response_if_id(&response, update_source)?;
}
Ok(())

View File

@@ -1322,14 +1322,14 @@ pub struct HttpResponse {
pub request_id: String,
pub body_path: Option<String>,
pub content_length: Option<i64>,
pub content_length_compressed: Option<i64>,
pub content_length: Option<i32>,
pub content_length_compressed: Option<i32>,
pub elapsed: i32,
pub elapsed_headers: i32,
pub error: Option<String>,
pub headers: Vec<HttpResponseHeader>,
pub remote_addr: Option<String>,
pub request_content_length: Option<i64>,
pub request_content_length: Option<i32>,
pub request_headers: Vec<HttpResponseHeader>,
pub status: i32,
pub status_reason: Option<String>,

View File

@@ -12,7 +12,7 @@ export type HttpRequest = { model: "http_request", id: string, createdAt: string
export type HttpRequestHeader = { enabled?: boolean, name: string, value: string, id?: string, };
export type HttpResponse = { model: "http_response", id: string, createdAt: string, updatedAt: string, workspaceId: string, requestId: string, bodyPath: string | null, contentLength: bigint | null, contentLengthCompressed: bigint | null, elapsed: number, elapsedHeaders: number, error: string | null, headers: Array<HttpResponseHeader>, remoteAddr: string | null, requestContentLength: bigint | null, requestHeaders: Array<HttpResponseHeader>, status: number, statusReason: string | null, state: HttpResponseState, url: string, version: string | null, };
export type HttpResponse = { model: "http_response", id: string, createdAt: string, updatedAt: string, workspaceId: string, requestId: string, bodyPath: string | null, contentLength: number | null, contentLengthCompressed: number | null, elapsed: number, elapsedHeaders: number, error: string | null, headers: Array<HttpResponseHeader>, remoteAddr: string | null, requestContentLength: number | null, requestHeaders: Array<HttpResponseHeader>, status: number, statusReason: string | null, state: HttpResponseState, url: string, version: string | null, };
export type HttpResponseHeader = { name: string, value: string, };

View File

@@ -37,7 +37,7 @@ import { getCreateDropdownItems } from '../hooks/useCreateDropdownItems';
import { getGrpcRequestActions } from '../hooks/useGrpcRequestActions';
import { useHotKey } from '../hooks/useHotKey';
import { getHttpRequestActions } from '../hooks/useHttpRequestActions';
import { getWebSocketRequestActions } from '../hooks/useWebSocketRequestActions';
import { getWebsocketRequestActions } from '../hooks/useWebsocketRequestActions';
import { getFolderActions } from '../hooks/useFolderActions';
import { useListenToTauriEvent } from '../hooks/useListenToTauriEvent';
import { getModelAncestors } from '../hooks/useModelAncestors';
@@ -377,7 +377,7 @@ function Sidebar({ className }: { className?: string }) {
},
})),
...(items.length === 1 && child.model === 'websocket_request'
? await getWebSocketRequestActions()
? await getWebsocketRequestActions()
: []
).map((a) => ({
label: a.label,

View File

@@ -103,7 +103,16 @@ export const WorkspaceActionsDropdown = memo(function WorkspaceActionsDropdown({
];
return { workspaceItems, itemsAfter };
}, [workspaces, workspaceMeta, deleteSendHistory, createWorkspace, workspace?.id]);
}, [
workspaces,
workspaceMeta,
deleteSendHistory,
createWorkspace,
workspace?.id,
workspace,
workspaceActions.map,
workspaceActions.length,
]);
const handleSwitchWorkspace = useCallback(async (workspaceId: string | null) => {
if (workspaceId == null) return;

View File

@@ -1,24 +1,24 @@
import { useQuery } from '@tanstack/react-query';
import type { WebsocketRequest } from '@yaakapp-internal/models';
import type {
CallWebSocketRequestActionRequest,
GetWebSocketRequestActionsResponse,
WebSocketRequestAction,
CallWebsocketRequestActionRequest,
GetWebsocketRequestActionsResponse,
WebsocketRequestAction,
} from '@yaakapp-internal/plugins';
import { useMemo } from 'react';
import { invokeCmd } from '../lib/tauri';
import { usePluginsKey } from './usePlugins';
export type CallableWebSocketRequestAction = Pick<WebSocketRequestAction, 'label' | 'icon'> & {
export type CallableWebSocketRequestAction = Pick<WebsocketRequestAction, 'label' | 'icon'> & {
call: (request: WebsocketRequest) => Promise<void>;
};
export function useWebSocketRequestActions() {
export function useWebsocketRequestActions() {
const pluginsKey = usePluginsKey();
const actionsResult = useQuery<CallableWebSocketRequestAction[]>({
queryKey: ['websocket_request_actions', pluginsKey],
queryFn: () => getWebSocketRequestActions(),
queryFn: () => getWebsocketRequestActions(),
});
// biome-ignore lint/correctness/useExhaustiveDependencies: none
@@ -29,16 +29,16 @@ export function useWebSocketRequestActions() {
return actions;
}
export async function getWebSocketRequestActions() {
const responses = await invokeCmd<GetWebSocketRequestActionsResponse[]>(
export async function getWebsocketRequestActions() {
const responses = await invokeCmd<GetWebsocketRequestActionsResponse[]>(
'cmd_websocket_request_actions',
);
const actions = responses.flatMap((r) =>
r.actions.map((a, i) => ({
r.actions.map((a: WebsocketRequestAction, i: number) => ({
label: a.label,
icon: a.icon,
call: async (websocketRequest: WebsocketRequest) => {
const payload: CallWebSocketRequestActionRequest = {
const payload: CallWebsocketRequestActionRequest = {
index: i,
pluginRefId: r.pluginRefId,
args: { websocketRequest },