diff options
author | Colin Reeder <colin@vpzom.click> | 2020-07-07 23:55:43 -0600 |
---|---|---|
committer | Colin Reeder <colin@vpzom.click> | 2020-07-07 23:55:43 -0600 |
commit | ad306994f663550731f0c6a519f645b0d22cbc0a (patch) | |
tree | 4de1bd0a9e573702d00a08c2868ab41c10257774 /src/routes/posts.rs | |
parent | e993e8615558507c49ee239cf5b60704ff77e1b5 (diff) |
Disable action buttons when already performed (#47)
Diffstat (limited to 'src/routes/posts.rs')
-rw-r--r-- | src/routes/posts.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/routes/posts.rs b/src/routes/posts.rs index 25d7089..0a41490 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -2,7 +2,7 @@ use super::{ fetch_base_data, get_cookie_map_for_headers, get_cookie_map_for_req, html_response, res_to_error, with_auth, }; -use crate::components::{Comment, CommunityLink, Content, HTPage, UserLink}; +use crate::components::{BoolSubmitButton, Comment, CommunityLink, Content, HTPage, UserLink}; use crate::resp_types::RespPostInfo; use crate::util::author_is_me; use std::sync::Arc; @@ -22,8 +22,14 @@ async fn page_post( ctx.http_client .request(with_auth( hyper::Request::get(format!( - "{}/api/unstable/posts/{}", - ctx.backend_host, post_id + "{}/api/unstable/posts/{}{}", + ctx.backend_host, + post_id, + if base_data.login.is_some() { + "?include_your=true" + } else { + "" + }, )) .body(Default::default())?, &cookies, @@ -47,7 +53,7 @@ async fn page_post( if base_data.login.is_some() { Some(render::rsx! { <form method={"POST"} action={format!("/posts/{}/like", post_id)}> - <button r#type={"submit"}>{"Like"}</button> + <BoolSubmitButton value={post.your_vote.is_some()} do_text={"Like"} done_text={"Liked"} /> </form> }) } else { |