diff --git a/frontend/src/main.rs b/frontend/src/main.rs index a9b3d6f..66e276d 100644 --- a/frontend/src/main.rs +++ b/frontend/src/main.rs @@ -116,6 +116,7 @@ async fn VisitsCount(cx: Scope<'_>) -> View { // app_state.books.get().num_found //); let app_state = app_state.clone(); + app_state.search.track(); spawn_local(async move { app_state.books.set( fetch_books(app_state.search.get().to_string()) @@ -127,12 +128,12 @@ async fn VisitsCount(cx: Scope<'_>) -> View { // let lbooks = fetch_books("lord of the rings".to_string()).await.unwrap(); view! {cx, - p { - "Total visits: " - span { - //(search) - (app_state.books.get().num_found) - } + p { + (if !app_state.search.get().is_empty() { + view!{cx,span {(app_state.books.get().num_found)} } + }else { + view! { cx, span { "World" } } + }) } } } @@ -153,28 +154,6 @@ fn App(cx: Scope) -> View { VisitsCount {} } } - /* - Router { - integration: {HistoryIntegration::new()}, - view: |cx, route: &ReadSignal| { - view! { - div(class="app") { - (match route.get().as_ref() { - AppRoutes::Home => view! { cx, - "This is the index page" - }, - AppRoutes::HelloServer => view! { cx, - "About this website" - }, - AppRoutes::NotFound => view! { cx, - "404 Not Found" - }, - }) - } - } - } - } - */ } }