From 89b2b598f401913012d1a29015086dfe32b2dd52 Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 11 Aug 2024 14:56:42 +0200 Subject: [PATCH] feat(web): jank search page should actually store the results in cache and do the same thing i do for timelines... oh well! --- web/src/page/search.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/web/src/page/search.rs b/web/src/page/search.rs index e32444e..accad30 100644 --- a/web/src/page/search.rs +++ b/web/src/page/search.rs @@ -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::(&search, auth).await.ok() } + } + ); + view! {
@@ -54,5 +63,24 @@ pub fn SearchPage() -> impl IntoView {
+ + {move || match text_search.get() { + None => Some(view! {

searching...

}.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!!! + +
+ }.into_view() + } + / > + }.into_view()) + }} } }