diff --git a/web/src/page.rs b/web/src/page.rs index 6d8e4fb9..f58305a0 100644 --- a/web/src/page.rs +++ b/web/src/page.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use apb::{Actor, Base, Collection, Object}; +use apb::{ActivityMut, Actor, Base, Collection, Object, ObjectMut}; use leptos::*; use leptos_router::*; @@ -32,6 +32,19 @@ pub fn ConfigPage() -> impl IntoView { } } +fn send_follow_request(target: String) { + let auth = use_context::().expect("missing auth context"); + spawn_local(async move { + let payload = serde_json::Value::Object(serde_json::Map::default()) + .set_activity_type(Some(apb::ActivityType::Follow)) + .set_object(apb::Node::link(target.clone())) + .set_to(apb::Node::links(vec![target])); + if let Err(e) = Http::post(&auth.outbox(), &payload, auth).await { + tracing::error!("failed sending follow request: {e}"); + } + }) +} + #[component] pub fn UserPage(tl: Timeline) -> impl IntoView { let params = use_params_map(); @@ -91,18 +104,25 @@ pub fn UserPage(tl: Timeline) -> impl IntoView { if !tl.next.get().starts_with(&tl_url) { tl.reset(tl_url); } + let _uid = uid.clone(); // TODO ughhhh + let followed_by_me = object.audience() + .get() + .filter(|x| x.ordered_items().is_empty()) // TODO check if contains my uid + .map(|_| view! { }.into_view()) + .unwrap_or(view! { following }.into_view()); + + // let following_me = object.generator() + // .get() + // .filter(|x| !x.ordered_items().is_empty()) // TODO check if contains my uid + // .map(|_| view! { }); + view! {