feat(web): crude way to show in_reply_to

This commit is contained in:
əlemi 2024-04-18 04:26:57 +02:00
parent 5f8d8be05a
commit 1734b6078b
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -92,6 +92,8 @@ pub fn ActorBanner(
#[component] #[component]
pub fn Object(object: serde_json::Value) -> impl IntoView { pub fn Object(object: serde_json::Value) -> impl IntoView {
let oid = object.id().unwrap_or_default().to_string();
let in_reply_to = object.in_reply_to().id().unwrap_or_default();
let summary = object.summary().unwrap_or_default().to_string(); let summary = object.summary().unwrap_or_default().to_string();
let content = dissolve::strip_html_tags(object.content().unwrap_or_default()); let content = dissolve::strip_html_tags(object.content().unwrap_or_default());
let date = object.published(); let date = object.published();
@ -100,15 +102,22 @@ pub fn Object(object: serde_json::Value) -> impl IntoView {
view! { view! {
<div> <div>
<table class="w-100 post-table pa-1 mb-s" > <table class="w-100 post-table pa-1 mb-s" >
{move || if !in_reply_to.is_empty() {
Some(view! {
<tr class="post-table" >
<td class="post-table pa-1" colspan="2" >
"in reply to "<small><a class="clean hover" href={in_reply_to.clone()} target="_blank">{Uri::pretty(&in_reply_to)}</a></small>
</td>
</tr>
})
} else { None }}
{move || if !summary.is_empty() { {move || if !summary.is_empty() {
view! { Some(view! {
<tr class="post-table" > <tr class="post-table" >
<td class="post-table pa-1" colspan="2" >{summary.clone()}</td> <td class="post-table pa-1" colspan="2" >{summary.clone()}</td>
</tr> </tr>
}.into_view() })
} else { } else { None }}
view! { }.into_view()
}}
<tr class="post-table" > <tr class="post-table" >
<td class="post-table pa-1" colspan="2" >{ <td class="post-table pa-1" colspan="2" >{
content.into_iter().map(|x| view! { <p>{x}</p> }).collect_view() content.into_iter().map(|x| view! { <p>{x}</p> }).collect_view()
@ -116,7 +125,11 @@ pub fn Object(object: serde_json::Value) -> impl IntoView {
</tr> </tr>
<tr class="post-table" > <tr class="post-table" >
<td class="post-table pa-1" ><ActorBanner object=author tiny=true /></td> <td class="post-table pa-1" ><ActorBanner object=author tiny=true /></td>
<td class="post-table pa-1 center" ><DateTime t=date /></td> <td class="post-table pa-1 center" >
<a class="clean hover" href={oid} target="_blank">
<DateTime t=date />
</a>
</td>
</tr> </tr>
</table> </table>
</div> </div>