forked from alemi/upub
fix(web): iter nodes and links not objects
This commit is contained in:
parent
141946444f
commit
c3e319d5a9
1 changed files with 49 additions and 43 deletions
|
@ -1,7 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use leptos::*;
|
||||
use regex::Regex;
|
||||
use crate::prelude::*;
|
||||
|
||||
use apb::{field::OptionalString, target::Addressed, ActivityMut, Base, Collection, CollectionMut, Object, ObjectMut};
|
||||
|
@ -49,10 +48,17 @@ pub fn Object(
|
|||
</a>
|
||||
});
|
||||
|
||||
let hashtag_badges = object.tag().filter_map(|x| {
|
||||
match apb::Link::link_type(&x) {
|
||||
let tag_badges = object.tag()
|
||||
.flat()
|
||||
.into_iter()
|
||||
.filter_map(|node| match node {
|
||||
apb::Node::Link(x) => Some(x),
|
||||
_ => None,
|
||||
})
|
||||
.map(|link| {
|
||||
match apb::Link::link_type(link.as_ref()) {
|
||||
Ok(apb::LinkType::Hashtag) => {
|
||||
let name = apb::Link::name(&x).unwrap_or_default().replace('#', "");
|
||||
let name = apb::Link::name(link.as_ref()).unwrap_or_default().replace('#', "");
|
||||
let href = Uri::web(U::Hashtag, &name);
|
||||
Some(view! {
|
||||
<a class="clean dim" href={href}>
|
||||
|
@ -66,8 +72,8 @@ pub fn Object(
|
|||
})
|
||||
},
|
||||
Ok(apb::LinkType::Mention) => {
|
||||
let uid = apb::Link::href(&x);
|
||||
let mention = apb::Link::name(&x).unwrap_or_default().replacen('@', "", 1);
|
||||
let uid = apb::Link::href(link.as_ref());
|
||||
let mention = apb::Link::name(link.as_ref()).unwrap_or_default().replacen('@', "", 1);
|
||||
let (username, domain) = if let Some((username, server)) = mention.split_once('@') {
|
||||
(username.to_string(), server.to_string())
|
||||
} else {
|
||||
|
@ -157,7 +163,7 @@ pub fn Object(
|
|||
</table>
|
||||
{post}
|
||||
<div class="mt-s ml-1 rev">
|
||||
{hashtag_badges}
|
||||
{tag_badges}
|
||||
{audience_badge}
|
||||
<span style="white-space:nowrap">
|
||||
<ReplyButton n=comments target=oid.clone() />
|
||||
|
|
Loading…
Reference in a new issue