diff --git a/web/index.html b/web/index.html index 476217cd..97418f42 100644 --- a/web/index.html +++ b/web/index.html @@ -144,6 +144,11 @@ background-color: var(--background); border: .3em solid #BF616A; } + img.avatar-inline { + display: inline; + height: .75em; + border-radius: 50%; + } img.inline-avatar { max-height: 2em; } diff --git a/web/src/components/activity.rs b/web/src/components/activity.rs new file mode 100644 index 00000000..a68339e8 --- /dev/null +++ b/web/src/components/activity.rs @@ -0,0 +1,42 @@ + +use leptos::*; +use crate::prelude::*; + +use apb::{target::Addressed, Activity, Actor, Base, Object}; + + +#[component] +pub fn ActivityLine(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 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 avatar = actor.icon().get().map(|x| x.url().id().unwrap_or_default()).unwrap_or_default(); + let username = actor.preferred_username().unwrap_or_default().to_string(); + let domain = actor.id().unwrap_or_default().replace("https://", "").split('/').next().unwrap_or_default().to_string(); + let kind = activity.activity_type().unwrap_or(apb::ActivityType::Activity); + view! { +
+ + {username}@{domain} + + | +
+ {kind.as_ref().to_string()}
+
+ |
+
+ "in reply to "{Uri::pretty(&in_reply_to)} + | +|
{summary.clone()} | +|
{
+ content.into_iter().map(|x| view! { {x} }).collect_view() + } |
+ |
+
+ |
+
+
+ |
+
+ {if summary.is_empty() { None } else { Some(view! {+ } +} + diff --git a/web/src/timeline.rs b/web/src/components/timeline.rs similarity index 85% rename from web/src/timeline.rs rename to web/src/components/timeline.rs index 729213bf..0efb05e3 100644 --- a/web/src/timeline.rs +++ b/web/src/components/timeline.rs @@ -1,6 +1,6 @@ use std::collections::BTreeSet; -use apb::Base; +use apb::{Activity, Base}; use leptos::*; use crate::prelude::*; @@ -53,13 +53,20 @@ pub fn TimelineFeed(tl: Timeline) -> impl IntoView { key=|k| k.to_string() children=move |id: String| { match CACHE.get(&id) { - Some(object) => match object.base_type() { - Some(apb::BaseType::Object(apb::ObjectType::Activity(_))) => view! { -{summary}
})}} + {content.into_iter().map(|x| view! {{x}
}).collect_view()} +
type not implemented