use leptos::*; use crate::{prelude::*, URL_SENSITIVE}; use apb::{target::Addressed, Base, Object}; #[component] pub fn Attachment( object: serde_json::Value, #[prop(optional)] sensitive: bool ) -> impl IntoView { let (expand, set_expand) = create_signal(false); let href = object.url().id().unwrap_or_default(); let media_type = object.media_type() .unwrap_or("image/png") // TODO weird defaulting to png????? .to_string(); let kind = media_type .split('/') .next() .unwrap_or("image") .to_string(); match kind.as_str() { "image" => view! {
}.into_view(), "video" => view! {
}.into_view(), "audio" => view! {
}.into_view(), _ => view! {
{object.name().unwrap_or_default().to_string()}
}.into_view(), } } #[component] pub fn Object(object: serde_json::Value) -> impl IntoView { let uid = object.id().unwrap_or_default().to_string(); let content = dissolve::strip_html_tags(object.content().unwrap_or_default()); let author_id = object.attributed_to().id().unwrap_or_default(); let author = CACHE.get_or(&author_id, serde_json::Value::String(author_id.clone())); let sensitive = object.sensitive().unwrap_or_default(); let attachments = object.attachment() .map(|x| view! {
{object.in_reply_to().id().map(|reply| view! {
reply
})}
|
} } #[component] pub fn Summary(summary: Option{content.into_iter().map(|x| view! { {x}
}).collect_view()} {attachments_padding} {attachments}
{summary}