Remove expects from request sending

This commit is contained in:
Gregory Schier
2023-04-04 08:14:32 -07:00
parent 107db42c33
commit 7d2ba43463
2 changed files with 31 additions and 8 deletions

View File

@@ -186,12 +186,23 @@ async fn actually_send_ephemeral_request(
let raw_response = client.execute(sendable_req).await;
let p = app_handle
.path_resolver()
.resolve_resource("plugins/plugin.ts")
.expect("failed to resolve resource");
let plugin_rel_path = "plugins/plugin.ts";
let plugin_path = match app_handle.path_resolver().resolve_resource(plugin_rel_path) {
Some(p) => p,
None => {
return response_err(
response,
format!("Plugin not found at {}", plugin_rel_path),
&app_handle,
pool,
)
.await;
}
};
runtime::run_plugin_sync(p.to_str().unwrap()).unwrap();
if let Err(e) = runtime::run_plugin_sync(plugin_path.to_str().unwrap()) {
return response_err(response, e.to_string(), &app_handle, pool).await;
}
match raw_response {
Ok(v) => {

View File

@@ -18,6 +18,7 @@ import { Icon } from './core/Icon';
import { IconButton } from './core/IconButton';
import { HStack } from './core/Stacks';
import { StatusColor } from './core/StatusColor';
import type { TabItem } from './core/Tabs/Tabs';
import { TabContent, Tabs } from './core/Tabs/Tabs';
import { Webview } from './core/Webview';
import { EmptyStateText } from './EmptyStateText';
@@ -53,9 +54,20 @@ export const ResponsePane = memo(function ResponsePane({ style, className }: Pro
[activeResponse],
);
const tabs = useMemo(
const tabs: TabItem[] = useMemo(
() => [
{ label: 'Preview', value: 'body' },
{
value: 'body',
label: 'Preview',
options: {
value: viewMode,
onChange: toggleViewMode,
items: [
{ label: 'Pretty', value: 'pretty' },
{ label: 'Raw', value: 'raw' },
],
},
},
{
label: (
<div className="flex items-center">
@@ -68,7 +80,7 @@ export const ResponsePane = memo(function ResponsePane({ style, className }: Pro
value: 'headers',
},
],
[activeResponse?.headers],
[activeResponse?.headers, toggleViewMode, viewMode],
);
return (