From e783ca227633cd9b69bff3794e5550b8b672e26e Mon Sep 17 00:00:00 2001 From: alemi Date: Fri, 7 Jun 2024 02:16:14 +0200 Subject: [PATCH] fix(web): replies filtering now should catch all cases --- web/src/components/timeline.rs | 35 ++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/web/src/components/timeline.rs b/web/src/components/timeline.rs index 91b592a..a47a12b 100644 --- a/web/src/components/timeline.rs +++ b/web/src/components/timeline.rs @@ -84,29 +84,36 @@ pub fn TimelineRepliesRecursive(tl: Timeline, root: String) -> impl IntoView { .get() .into_iter() .filter_map(|x| CACHE.get(&x)) - .filter(|x| match x.object_type() { - Ok(apb::ObjectType::Activity(apb::ActivityType::Create)) => { - let Some(oid) = x.object().id().str() else { return false; }; - let Some(object) = CACHE.get(&oid) else { return false; }; - let Some(reply) = object.in_reply_to().id().str() else { return false; }; - reply == root - }, - Ok(apb::ObjectType::Activity(_)) => x.object().id().map(|o| o == root).unwrap_or(false), - _ => x.in_reply_to().id().map(|r| r == root).unwrap_or(false), + .filter_map(|x| { + let oid = match x.object_type().ok()? { + // if it's a create, get and check created object: does it reply to root? + apb::ObjectType::Activity(apb::ActivityType::Create) => + CACHE.get(x.object().id().ok()?)?.in_reply_to().id().str()?, + + // if it's a raw note, directly check if it replies to root + apb::ObjectType::Note => x.in_reply_to().id().str()?, + + // 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::>(); + .collect::>(); view! {
- +
}