fix(web): replies filtering now should catch all cases

This commit is contained in:
əlemi 2024-06-07 02:16:14 +02:00
parent dfbce8aa38
commit e783ca2276
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -84,29 +84,36 @@ pub fn TimelineRepliesRecursive(tl: Timeline, root: String) -> impl IntoView {
.get() .get()
.into_iter() .into_iter()
.filter_map(|x| CACHE.get(&x)) .filter_map(|x| CACHE.get(&x))
.filter(|x| match x.object_type() { .filter_map(|x| {
Ok(apb::ObjectType::Activity(apb::ActivityType::Create)) => { let oid = match x.object_type().ok()? {
let Some(oid) = x.object().id().str() else { return false; }; // if it's a create, get and check created object: does it reply to root?
let Some(object) = CACHE.get(&oid) else { return false; }; apb::ObjectType::Activity(apb::ActivityType::Create) =>
let Some(reply) = object.in_reply_to().id().str() else { return false; }; CACHE.get(x.object().id().ok()?)?.in_reply_to().id().str()?,
reply == root
}, // if it's a raw note, directly check if it replies to root
Ok(apb::ObjectType::Activity(_)) => x.object().id().map(|o| o == root).unwrap_or(false), apb::ObjectType::Note => x.in_reply_to().id().str()?,
_ => x.in_reply_to().id().map(|r| r == root).unwrap_or(false),
// if it's anything else, check if it relates to root, maybe like or announce?
_ => x.object().id().str()?,
};
if oid == root {
Some((oid, x))
} else {
None
}
}) })
.collect::<Vec<crate::Object>>(); .collect::<Vec<(String, crate::Object)>>();
view! { view! {
<For <For
each=root_values each=root_values
key=|k| k.id().unwrap_or_default().to_string() key=|(id, _obj)| id.clone()
children=move |obj: crate::Object| { children=move |(id, obj)| {
let oid = obj.id().unwrap_or_default().to_string();
view! { view! {
<div class="context depth-r"> <div class="context depth-r">
<Item item=obj replies=true /> <Item item=obj replies=true />
<div class="depth-r"> <div class="depth-r">
<TimelineRepliesRecursive tl=tl root=oid /> <TimelineRepliesRecursive tl=tl root=id />
</div> </div>
</div> </div>
} }