This commit is contained in:
2022-10-09 20:17:34 +05:30
parent 48ab7519f2
commit 9351d61f70

View File

@@ -116,6 +116,7 @@ async fn VisitsCount<G: Html>(cx: Scope<'_>) -> View<G> {
// app_state.books.get().num_found // app_state.books.get().num_found
//); //);
let app_state = app_state.clone(); let app_state = app_state.clone();
app_state.search.track();
spawn_local(async move { spawn_local(async move {
app_state.books.set( app_state.books.set(
fetch_books(app_state.search.get().to_string()) fetch_books(app_state.search.get().to_string())
@@ -127,12 +128,12 @@ async fn VisitsCount<G: Html>(cx: Scope<'_>) -> View<G> {
// let lbooks = fetch_books("lord of the rings".to_string()).await.unwrap(); // let lbooks = fetch_books("lord of the rings".to_string()).await.unwrap();
view! {cx, view! {cx,
p { p {
"Total visits: " (if !app_state.search.get().is_empty() {
span { view!{cx,span {(app_state.books.get().num_found)} }
//(search) }else {
(app_state.books.get().num_found) view! { cx, span { "World" } }
} })
} }
} }
} }
@@ -153,28 +154,6 @@ fn App<G: Html>(cx: Scope) -> View<G> {
VisitsCount {} VisitsCount {}
} }
} }
/*
Router {
integration: {HistoryIntegration::new()},
view: |cx, route: &ReadSignal<AppRoutes>| {
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"
},
})
}
}
}
}
*/
} }
} }