fix(web): properly process and display search results
This commit is contained in:
parent
86b0569cd2
commit
01de917bdb
2 changed files with 15 additions and 10 deletions
|
@ -31,7 +31,10 @@ pub fn SearchPage() -> impl IntoView {
|
||||||
move || use_query_map().get().get("q").cloned().unwrap_or_default(),
|
move || use_query_map().get().get("q").cloned().unwrap_or_default(),
|
||||||
move |q| {
|
move |q| {
|
||||||
let search = format!("{URL_BASE}/search?q={q}");
|
let search = format!("{URL_BASE}/search?q={q}");
|
||||||
async move { Http::fetch::<serde_json::Value>(&search, auth).await.ok() }
|
async move {
|
||||||
|
let items = Http::fetch::<serde_json::Value>(&search, auth).await.ok()?;
|
||||||
|
Some(crate::timeline::process_activities(items.ordered_items().collect(), auth).await)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -73,16 +76,17 @@ pub fn SearchPage() -> impl IntoView {
|
||||||
None => Some(view! { <p class="center"><small>searching...</small></p> }.into_view()),
|
None => Some(view! { <p class="center"><small>searching...</small></p> }.into_view()),
|
||||||
Some(None) => None,
|
Some(None) => None,
|
||||||
Some(Some(items)) => Some(view! {
|
Some(Some(items)) => Some(view! {
|
||||||
// TODO this is jank af! i should do the same thing i do for timelines, aka first process
|
// TODO ughhh too many clones
|
||||||
// all items and store in cache and then pass a vec of strings here!!!
|
|
||||||
<For
|
<For
|
||||||
each=move || items.ordered_items()
|
each=move || items.clone()
|
||||||
key=|item| item.id().unwrap_or_default().to_string()
|
key=|id| id.clone()
|
||||||
children=move |item| {
|
children=move |item| {
|
||||||
view! {
|
cache::OBJECTS.get(&item)
|
||||||
<Item item=item.into() />
|
.map(|x| view! {
|
||||||
|
<Item item=x />
|
||||||
<hr />
|
<hr />
|
||||||
}.into_view()
|
}.into_view()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/ >
|
/ >
|
||||||
}.into_view())
|
}.into_view())
|
||||||
|
|
|
@ -100,7 +100,8 @@ impl Timeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn process_activities(activities: Vec<serde_json::Value>, auth: Auth) -> Vec<String> {
|
// TODO ughhh this shouldn't be here if its pub!!!
|
||||||
|
pub async fn process_activities(activities: Vec<serde_json::Value>, auth: Auth) -> Vec<String> {
|
||||||
let mut sub_tasks : Vec<Pin<Box<dyn futures::Future<Output = ()>>>> = Vec::new();
|
let mut sub_tasks : Vec<Pin<Box<dyn futures::Future<Output = ()>>>> = Vec::new();
|
||||||
let mut gonna_fetch = BTreeSet::new();
|
let mut gonna_fetch = BTreeSet::new();
|
||||||
let mut actors_seen = BTreeSet::new();
|
let mut actors_seen = BTreeSet::new();
|
||||||
|
|
Loading…
Reference in a new issue