Skip to content

Commit

Permalink
chore: clone data before processing title and content in publisher co…
Browse files Browse the repository at this point in the history
…mponent
  • Loading branch information
Michael-Liendo committed Sep 27, 2024
1 parent 1a76217 commit 81621c1
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions crates/web/src/components/publisher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ pub fn Publisher() -> impl IntoView {
let creation_error: RwSignal<Option<String>> = 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
Expand All @@ -38,7 +38,7 @@ pub fn Publisher() -> impl IntoView {
content,
parent_id: None,
})
.await
.await;
}
});

Expand Down

0 comments on commit 81621c1

Please sign in to comment.