use leptos::*; use crate::prelude::*; use apb::{target::Addressed, Activity, Actor, Base, Object}; #[component] pub fn InlineActivity(activity: serde_json::Value) -> impl IntoView { let object_id = activity.object().id().unwrap_or_default(); let object = CACHE.get(&object_id).unwrap_or(serde_json::Value::String(object_id.clone())); let addressed = activity.addressed(); let audience = format!("[ {} ]", addressed.join(", ")); let actor_id = activity.actor().id().unwrap_or_default(); let actor = match CACHE.get(&actor_id) { Some(a) => a, None => serde_json::Value::String(actor_id.clone()), }; let privacy = if addressed.iter().any(|x| x == apb::target::PUBLIC) { "🌐" } else if addressed.iter().any(|x| x.ends_with("/followers")) { "🔒" } else { "🔗" }; let date = object.published().or(activity.published()); let kind = activity.activity_type().unwrap_or(apb::ActivityType::Activity); view! {
{match kind { // post apb::ActivityType::Create => view! {{display_name} | |
{username}@{domain} |
{summary.clone()} | |
{
content.into_iter().map(|x| view! { {x} }).collect_view() } |
|
{summary}
})}}
{content.into_iter().map(|x| view! {} } #[component] pub fn DateTime(t: Option{x}
}).collect_view()}