feat(web): jank search page
should actually store the results in cache and do the same thing i do for timelines... oh well!
This commit is contained in:
parent
b427000364
commit
89b2b598f4
1 changed files with 28 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use apb::{Base, Collection};
|
||||
use leptos::*;
|
||||
use leptos_router::*;
|
||||
use crate::prelude::*;
|
||||
|
@ -24,6 +25,14 @@ pub fn SearchPage() -> impl IntoView {
|
|||
}
|
||||
);
|
||||
|
||||
let text_search = create_local_resource(
|
||||
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() }
|
||||
}
|
||||
);
|
||||
|
||||
view! {
|
||||
<blockquote class="mt-3 mb-3">
|
||||
<details open>
|
||||
|
@ -54,5 +63,24 @@ pub fn SearchPage() -> impl IntoView {
|
|||
</div>
|
||||
</details>
|
||||
</blockquote>
|
||||
|
||||
{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!!!
|
||||
<For
|
||||
each=move || items.ordered_items()
|
||||
key=|item| item.id().unwrap_or_default().to_string()
|
||||
children=move |item| {
|
||||
view! {
|
||||
<Item item=item.into() />
|
||||
<hr />
|
||||
}.into_view()
|
||||
}
|
||||
/ >
|
||||
}.into_view())
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue