Remove expects from request sending

This commit is contained in:
Gregory Schier
2023-04-04 08:14:32 -07:00
parent b2a7d95922
commit fcbe923770
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 raw_response = client.execute(sendable_req).await;
let p = app_handle let plugin_rel_path = "plugins/plugin.ts";
.path_resolver() let plugin_path = match app_handle.path_resolver().resolve_resource(plugin_rel_path) {
.resolve_resource("plugins/plugin.ts") Some(p) => p,
.expect("failed to resolve resource"); 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 { match raw_response {
Ok(v) => { Ok(v) => {

View File

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