From 4b632faf2aaa3b94ea115ef017bf0e091e3e7bb1 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 11 Nov 2024 01:19:33 +0100 Subject: [PATCH] fix(apb): remove ambiguous Iterator impl for node --- apb/src/node.rs | 26 -------------------------- web/src/actors/header.rs | 3 +++ web/src/objects/item.rs | 3 +++ web/src/page/search.rs | 12 +++++++++++- web/src/timeline/mod.rs | 3 +++ 5 files changed, 20 insertions(+), 27 deletions(-) diff --git a/apb/src/node.rs b/apb/src/node.rs index d5e2433..791cce5 100644 --- a/apb/src/node.rs +++ b/apb/src/node.rs @@ -41,32 +41,6 @@ impl From> for Node { } } -impl Iterator for Node { - type Item = T; - - fn next(&mut self) -> Option { - match std::mem::replace(self, Self::Empty) { - Self::Empty => None, - Self::Object(res) => Some(*res), - Self::Link(lnk) => { - *self = Self::Link(lnk); - None - }, - Self::Array(mut arr) => { - let mut out = None; - while let Some(res) = arr.pop_front() { - if let Some(inner) = res.extract() { - out = Some(inner); - break; - } - } - *self = Self::Array(arr); - out - } - } - } -} - impl Node { /// return reference to embedded object (or first if many are present) pub fn get(&self) -> Option<&T> { diff --git a/web/src/actors/header.rs b/web/src/actors/header.rs index 86d3c64..4036aae 100644 --- a/web/src/actors/header.rs +++ b/web/src/actors/header.rs @@ -42,6 +42,9 @@ pub fn ActorHeader() -> impl IntoView { Some(view! { "["{actor_type.as_ref().to_lowercase()}"]" } ) }; let fields = actor.attachment() + .flat() + .into_iter() + .filter_map(|x| x.extract()) .map(|x| view! { {x.name().str().unwrap_or_default()} diff --git a/web/src/objects/item.rs b/web/src/objects/item.rs index 2ac0355..21b8204 100644 --- a/web/src/objects/item.rs +++ b/web/src/objects/item.rs @@ -15,6 +15,9 @@ pub fn Object(object: crate::Object) -> impl IntoView { let public = addressed.iter().any(|x| x.as_str() == apb::target::PUBLIC); let external_url = object.url().id().str().unwrap_or_else(|| oid.clone()); let attachments = object.attachment() + .flat() + .into_iter() + .filter_map(|x| x.extract()) // TODO maybe show links? .map(|x| view! { }) .collect_view(); let comments = object.replies().get() diff --git a/web/src/page/search.rs b/web/src/page/search.rs index d09d5eb..fcb6cbd 100644 --- a/web/src/page/search.rs +++ b/web/src/page/search.rs @@ -35,7 +35,17 @@ pub fn SearchPage() -> impl IntoView { let search = format!("{URL_BASE}/search?q={q}"); async move { let items = Http::fetch::(&search, auth).await.ok()?; - Some(crate::timeline::process_activities(items.ordered_items().collect(), auth).await) + Some( + crate::timeline::process_activities( + items + .ordered_items() + .flat() + .into_iter() + .filter_map(|x| x.extract()) + .collect(), + auth + ).await + ) } } ); diff --git a/web/src/timeline/mod.rs b/web/src/timeline/mod.rs index 539a20e..2ce91b3 100644 --- a/web/src/timeline/mod.rs +++ b/web/src/timeline/mod.rs @@ -87,6 +87,9 @@ impl Timeline { let collection : serde_json::Value = Http::fetch(&feed_url, auth).await?; let activities : Vec = collection .ordered_items() + .flat() + .into_iter() + .filter_map(|x| x.extract()) .collect(); let mut feed = self.feed.get_untracked();