From 562dc22320ff045ac3eeb50cd4441d67a1a7a487 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 17 Apr 2024 06:46:59 +0200 Subject: [PATCH] feat(web): post box allows picking post privacy --- web/src/context.rs | 23 ++++++++------- web/src/lib.rs | 73 +++++++++++++++++++++++++++++++++------------- web/src/main.rs | 2 +- 3 files changed, 67 insertions(+), 31 deletions(-) diff --git a/web/src/context.rs b/web/src/context.rs index e7ea2e8..3037ea6 100644 --- a/web/src/context.rs +++ b/web/src/context.rs @@ -103,12 +103,12 @@ impl Uri { pub struct Http; impl Http { - pub async fn request( + pub async fn request( method: reqwest::Method, url: &str, - data: Option<&serde_json::Value>, + data: Option<&T>, token: Signal> - ) -> reqwest::Result { + ) -> reqwest::Result { let mut req = reqwest::Client::new() .request(method, url); @@ -122,17 +122,20 @@ impl Http { req.send() .await? - .error_for_status()? + .error_for_status() + } + + pub async fn fetch(url: &str, token: Signal>) -> reqwest::Result { + Self::request::<()>(reqwest::Method::GET, url, None, token) + .await? .json::() .await } - pub async fn fetch(url: &str, token: Signal>) -> reqwest::Result { - Self::request(reqwest::Method::GET, url, None, token).await - } - - pub async fn post(url: &str, data: &serde_json::Value, token: Signal>) -> reqwest::Result { - Self::request(reqwest::Method::POST, url, Some(data), token).await + pub async fn post(url: &str, data: &T, token: Signal>) -> reqwest::Result<()> { + Self::request(reqwest::Method::POST, url, Some(data), token) + .await?; + Ok(()) } } diff --git a/web/src/lib.rs b/web/src/lib.rs index aefef58..a58e694 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -115,31 +115,64 @@ pub fn TimelineNavigation() -> impl IntoView { } #[component] -pub fn PostBox() -> impl IntoView { +pub fn PostBox(username: Signal>) -> impl IntoView { let auth = use_context::>>().expect("missing auth context"); let summary_ref: NodeRef = create_node_ref(); let content_ref: NodeRef = create_node_ref(); + let public_ref: NodeRef = create_node_ref(); + let followers_ref: NodeRef = create_node_ref(); view! {
- - - + + + + + + + + + + + + +
+ +
+ +
} } diff --git a/web/src/main.rs b/web/src/main.rs index 6eae989..14c759d 100644 --- a/web/src/main.rs +++ b/web/src/main.rs @@ -71,7 +71,7 @@ fn main() {

- +