From f96f303cf52a0c127ee210b8b0a4e02ed9361d5c Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 5 Mar 2024 22:05:10 -0500 Subject: [PATCH] minor update --- devblog/devblog/client/src/components/comment.rs | 4 ++-- devblog/devblog/client/src/components/comment_edit.rs | 4 ++-- devblog/devblog/client/src/components/post.rs | 1 - devblog/devblog/client/src/components/post_edit.rs | 5 ++--- devblog/devblog/client/src/pages/test.md | 3 --- 5 files changed, 6 insertions(+), 11 deletions(-) delete mode 100644 devblog/devblog/client/src/pages/test.md diff --git a/devblog/devblog/client/src/components/comment.rs b/devblog/devblog/client/src/components/comment.rs index 40cbfab..fb921c8 100644 --- a/devblog/devblog/client/src/components/comment.rs +++ b/devblog/devblog/client/src/components/comment.rs @@ -58,14 +58,14 @@ pub fn comment(props: &Props) -> Html { // edit comment if !*is_editing && props.comment.username == store.username { } // delete comment - if props.comment.username == store.username || store.admin{ + if props.comment.username == store.username || store.admin { } diff --git a/devblog/devblog/client/src/components/comment_edit.rs b/devblog/devblog/client/src/components/comment_edit.rs index 591b72d..e89f0f4 100644 --- a/devblog/devblog/client/src/components/comment_edit.rs +++ b/devblog/devblog/client/src/components/comment_edit.rs @@ -20,7 +20,7 @@ pub struct Props { #[function_component(EditComment)] pub fn edit_comment(props: &Props) -> Html { let style = Style::new(STYLE).unwrap(); - let content = use_state(|| String::default()); + let content = use_state(|| props.content.clone()); let store = use_store_value::(); let onchange = { @@ -83,7 +83,7 @@ pub fn edit_comment(props: &Props) -> Html { if props.is_editing {
- +
diff --git a/devblog/devblog/client/src/components/post.rs b/devblog/devblog/client/src/components/post.rs index eef7b3c..db60b58 100644 --- a/devblog/devblog/client/src/components/post.rs +++ b/devblog/devblog/client/src/components/post.rs @@ -46,7 +46,6 @@ pub fn post(props: &Props) -> Html { Callback::from(move |id| { let mut new_comments = comments_clone.deref().clone(); if let Some(idx) = new_comments.iter().position(|c| c.id == id) { - // log!("IDXXXX: ", idx); new_comments.remove(idx); comments_clone.set(new_comments); } diff --git a/devblog/devblog/client/src/components/post_edit.rs b/devblog/devblog/client/src/components/post_edit.rs index 060f654..742c534 100644 --- a/devblog/devblog/client/src/components/post_edit.rs +++ b/devblog/devblog/client/src/components/post_edit.rs @@ -29,7 +29,6 @@ pub fn edit_post(props: &Props) -> Html { let description = description.deref().clone(); let token = store.token.clone(); let is_editing = is_editing.clone(); - let on_post_edit = props.on_post_edit.clone(); let id = props.id.clone(); Callback::from(move |e: SubmitEvent| { e.prevent_default(); @@ -37,7 +36,6 @@ pub fn edit_post(props: &Props) -> Html { let body = Some(helpers::to_jsvalue(description.deref())); let hdrs = helpers::create_auth_header(&token); hdrs.append("content-type", "application/json"); - let on_post_edit = on_post_edit.clone(); let is_editing = is_editing.clone(); wasm_bindgen_futures::spawn_local(async move { @@ -45,7 +43,6 @@ pub fn edit_post(props: &Props) -> Html { if let Some(res) = response { if res.status() == 200 { - on_post_edit.emit(description.clone()); is_editing.set(false); } } @@ -54,11 +51,13 @@ pub fn edit_post(props: &Props) -> Html { }; let on_description_change = { + let on_post_edit = props.on_post_edit.clone(); let description = description.clone(); Callback::from(move |e: InputEvent| { let input = e.target_dyn_into::(); if let Some(value) = input { description.set(value.value()); + on_post_edit.emit(value.value()); } }) }; diff --git a/devblog/devblog/client/src/pages/test.md b/devblog/devblog/client/src/pages/test.md deleted file mode 100644 index 9cec771..0000000 --- a/devblog/devblog/client/src/pages/test.md +++ /dev/null @@ -1,3 +0,0 @@ -# hello world - ---- \ No newline at end of file