about summary refs log tree commit diff
path: root/frontend/src/main.rs
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2022-10-30 17:36:45 +0100
committerBaitinq <manuelpalenzuelamerino@gmail.com>2022-10-30 17:52:53 +0100
commitcf3f11c76eb4aa9fdcf9ba9c32990dda97ae295b (patch)
tree5b1598be6a369c5ddd467e9aa6189c825eae1cf1 /frontend/src/main.rs
parentFrontend: Update yew to follow master (diff)
downloadOSSE-cf3f11c76eb4aa9fdcf9ba9c32990dda97ae295b.tar.gz
OSSE-cf3f11c76eb4aa9fdcf9ba9c32990dda97ae295b.tar.bz2
OSSE-cf3f11c76eb4aa9fdcf9ba9c32990dda97ae295b.zip
Frontend: Implement support for searching with /search/* routes
We now immediately search if we are in a /search/* route. This
implementation is not that good as we have to duplicate the code that
runs both when creating the component in  /search/* route and when
submitting a search query.
Diffstat (limited to '')
-rw-r--r--frontend/src/main.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/frontend/src/main.rs b/frontend/src/main.rs
index fd5ef3c..7f73cf7 100644
--- a/frontend/src/main.rs
+++ b/frontend/src/main.rs
@@ -9,17 +9,19 @@ use app::OSSE;
 enum Route {
     #[at("/")]
     OSSEHome,
+    #[at("/search/")]
+    OSSEHomeEmptySearch,
     #[at("/search/:query")]
     OSSESearch { query: String },
 }
 
 fn switch_routes(routes: Route) -> Html {
     match routes {
-        Route::OSSEHome => html! {
-            <OSSE api_endpoint={"http://127.0.0.1:4444"}/>
+        Route::OSSEHome | Route::OSSEHomeEmptySearch => html! {
+            <OSSE api_endpoint={"http://127.0.0.1:4444"} initial_search_query={None as Option<String>} />
         },
         Route::OSSESearch { query } => html! {
-            <OSSE api_endpoint={"http://127.0.0.1:4444"}/>
+            <OSSE api_endpoint={"http://127.0.0.1:4444"} initial_search_query={Some(query)} />
         },
     }
 }