Compare commits

...

2 commits

2 changed files with 36 additions and 22 deletions

View file

@ -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)
}
} }
); );
@ -42,7 +45,7 @@ pub fn SearchPage() -> impl IntoView {
<blockquote class="mt-3 mb-3"> <blockquote class="mt-3 mb-3">
<details open> <details open>
<summary class="mb-2"> <summary class="mb-2">
<code class="cw center color ml-s w-100">users</code> <code class="cw center color ml-s w-100">actor</code>
</summary> </summary>
<div class="pb-1"> <div class="pb-1">
{move || match user.get() { {move || match user.get() {
@ -57,7 +60,7 @@ pub fn SearchPage() -> impl IntoView {
<blockquote class="mt-3 mb-3"> <blockquote class="mt-3 mb-3">
<details open> <details open>
<summary class="mb-2"> <summary class="mb-2">
<code class="cw center color ml-s w-100">objects</code> <code class="cw center color ml-s w-100">object</code>
</summary> </summary>
<div class="pb-1"> <div class="pb-1">
{move || match object.get() { {move || match object.get() {
@ -69,23 +72,33 @@ pub fn SearchPage() -> impl IntoView {
</details> </details>
</blockquote> </blockquote>
{move || match text_search.get() { <blockquote class="mt-3 mb-3">
None => Some(view! { <p class="center"><small>searching...</small></p> }.into_view()), <details open>
Some(None) => None, <summary class="mb-2">
Some(Some(items)) => Some(view! { <code class="cw center color ml-s w-100">full text</code>
// TODO this is jank af! i should do the same thing i do for timelines, aka first process </summary>
// all items and store in cache and then pass a vec of strings here!!! <div class="pb-1">
<For {move || match text_search.get() {
each=move || items.ordered_items() None => Some(view! { <p class="center"><small>searching...</small></p> }.into_view()),
key=|item| item.id().unwrap_or_default().to_string() Some(None) => None,
children=move |item| { Some(Some(items)) => Some(view! {
view! { // TODO ughhh too many clones
<Item item=item.into() /> <For
<hr /> each=move || items.clone()
}.into_view() key=|id| id.clone()
} children=move |item| {
/ > cache::OBJECTS.get(&item)
}.into_view()) .map(|x| view! {
}} <Item item=x />
<hr />
}.into_view()
)
}
/ >
}.into_view())
}}
</div>
</details>
</blockquote>
} }
} }

View file

@ -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();