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