From dec17fc65be0040b839c916fba7f477048ad4082 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Wed, 3 Jan 2024 07:38:43 -0500 Subject: [PATCH] fix server actions and server multi actions --- leptos_server/src/action.rs | 16 ++++++---------- leptos_server/src/multi_action.rs | 13 ++++--------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/leptos_server/src/action.rs b/leptos_server/src/action.rs index 6052f6401..ef2eeae89 100644 --- a/leptos_server/src/action.rs +++ b/leptos_server/src/action.rs @@ -212,17 +212,17 @@ where any(debug_assertions, feature = "ssr"), tracing::instrument(level = "trace", skip_all,) )] - pub fn server() -> Action> + pub fn server() -> Action>> where I: ServerFn + Clone, { // The server is able to call the function directly #[cfg(feature = "ssr")] - let action_function = |args: &I| I::call_fn(args.clone(), ()); + let action_function = |args: &I| I::run_body(args.clone()); // When not on the server send a fetch to request the fn call. #[cfg(not(feature = "ssr"))] - let action_function = |args: &I| I::call_fn_client(args.clone(), ()); + let action_function = |args: &I| I::run_on_client(args.clone()); // create the action Action::new(action_function).using_server_fn::() @@ -267,13 +267,8 @@ where tracing::instrument(level = "trace", skip_all,) )] pub fn using_server_fn(self) -> Self { - let prefix = T::prefix(); self.0.update_value(|state| { - state.url = if prefix.is_empty() { - Some(T::url().to_string()) - } else { - Some(prefix.to_string() + "/" + T::url()) - }; + state.url = Some(T::url().to_string()); }); self } @@ -483,7 +478,8 @@ where any(debug_assertions, feature = "ssr"), tracing::instrument(level = "trace", skip_all,) )] -pub fn create_server_action() -> Action> +pub fn create_server_action( +) -> Action>> where S: Clone + ServerFn, { diff --git a/leptos_server/src/multi_action.rs b/leptos_server/src/multi_action.rs index bd9a7fa72..232e36b64 100644 --- a/leptos_server/src/multi_action.rs +++ b/leptos_server/src/multi_action.rs @@ -133,13 +133,8 @@ where tracing::instrument(level = "trace", skip_all,) )] pub fn using_server_fn(self) -> Self { - let prefix = T::prefix(); self.0.update_value(|a| { - a.url = if prefix.is_empty() { - Some(T::url().to_string()) - } else { - Some(prefix.to_string() + "/" + T::url()) - }; + a.url = Some(T::url().to_string()); }); self @@ -343,13 +338,13 @@ where tracing::instrument(level = "trace", skip_all,) )] pub fn create_server_multi_action( -) -> MultiAction> +) -> MultiAction>> where S: Clone + ServerFn, { #[cfg(feature = "ssr")] - let c = move |args: &S| S::call_fn(args.clone(), ()); + let c = move |args: &S| S::run_body(args.clone()); #[cfg(not(feature = "ssr"))] - let c = move |args: &S| S::call_fn_client(args.clone(), ()); + let c = move |args: &S| S::run_on_client(args.clone()); create_multi_action(c).using_server_fn::() }