diff --git a/crates/web/src/components/publisher/mod.rs b/crates/web/src/components/publisher/mod.rs index 7bed1a5..04eb7bd 100644 --- a/crates/web/src/components/publisher/mod.rs +++ b/crates/web/src/components/publisher/mod.rs @@ -14,22 +14,22 @@ pub fn Publisher() -> impl IntoView { let creation_error: RwSignal> = create_rw_signal(None); let send_post_action = create_action(move |data: &(String, String)| { - let (title, content) = data; + let (title, content) = data.clone(); - let title = title.trim().to_owned(); + async move { + let title = title.trim().to_owned(); - if title.is_empty() { - creation_error.set(Some("Title is required".to_owned())); - () - } + if title.is_empty() { + creation_error.set(Some("Title is required".to_owned())); + return; + } - let content = if content.is_empty() { - None - } else { - Some(content.trim().to_owned()) - }; + let content = if content.is_empty() { + None + } else { + Some(content.trim().to_owned()) + }; - async move { Client::new("http://127.0.0.1:8080") .unwrap() .post @@ -38,7 +38,7 @@ pub fn Publisher() -> impl IntoView { content, parent_id: None, }) - .await + .await; } });