diff --git a/web/src/context.rs b/web/src/context.rs index e7ea2e8e..3037ea66 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 aefef588..a58e694b 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 6eae9894..14c759d1 100644 --- a/web/src/main.rs +++ b/web/src/main.rs @@ -71,7 +71,7 @@ fn main() {

- +