diff --git a/web/src/lib.rs b/web/src/lib.rs index 4e3d3e93..60e76de5 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -3,6 +3,7 @@ use std::sync::Arc; use apb::{target::Addressed, Activity, ActivityMut, Actor, Base, Collection, Object, ObjectMut}; use dashmap::DashMap; use leptos::{leptos_dom::logging::console_log, *}; +use leptos_router::use_params_map; pub const BASE_URL: &str = "https://feditest.alemi.dev"; @@ -21,8 +22,9 @@ pub fn LoginBox( let password_ref: NodeRef = create_node_ref(); view! {
-
- + "Hello "test +
@@ -98,17 +100,15 @@ pub fn TimelinePicker( let (my_in, my_out, our_in, our_out) = targets.clone(); let (my_in_, my_out_, our_in_, our_out_) = targets; view! { -

- - - - -

+ + + + } } #[component] -pub fn Actor(object: serde_json::Value) -> impl IntoView { +pub fn ActorBanner(object: serde_json::Value) -> impl IntoView { match object { serde_json::Value::String(id) => view! {
{id}
@@ -138,6 +138,46 @@ pub fn Actor(object: serde_json::Value) -> impl IntoView { } } +#[component] +pub fn Actor() -> impl IntoView { + let params = use_params_map(); + let actor = create_local_resource(move || params.get().get("id").cloned().unwrap_or_default(), |uid| { + async move { + reqwest::get(format!("{BASE_URL}/users/{uid}")) + .await + .unwrap() + .json::() + .await + .unwrap() + } + }); + view! { + {move || match actor.get() { + None => view! {

loading...

}.into_view(), + Some(x) => view! { +
+ +

+ {x.actor_type().unwrap_or(apb::ActorType::Person).as_ref().to_string()} +

+

{x.summary().unwrap_or("").to_string()}

+
    +
  • following" "{x.following().get().map(|x| x.total_items().unwrap_or(0))}
  • +
  • followers" "{x.followers().get().map(|x| x.total_items().unwrap_or(0))}
  • +
  • created" "{x.published().map(|x| x.to_rfc3339())}
  • +
+
+ }.into_view(), + }} + } +} + #[component] pub fn Activity(activity: serde_json::Value) -> impl IntoView { let object = activity.clone().object().extract().unwrap_or_else(|| @@ -211,8 +251,8 @@ pub fn Timeline( serde_json::Value::String(object.actor().id().unwrap_or_default()) ); view! { -
- +
+

diff --git a/web/src/main.rs b/web/src/main.rs index fdb1825b..1b98e8a0 100644 --- a/web/src/main.rs +++ b/web/src/main.rs @@ -3,7 +3,7 @@ use leptos_router::*; use leptos_use::{use_cookie, utils::FromToStringCodec}; use upub_web::{ - LoginBox, PostBox, Timeline + Actor, LoginBox, PostBox, Timeline }; fn main() { @@ -15,7 +15,7 @@ fn main() {