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
//);
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())
@@ -128,11 +129,11 @@ async fn VisitsCount<G: Html>(cx: Scope<'_>) -> View<G> {
// 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)
}
(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<G: Html>(cx: Scope) -> View<G> {
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"
},
})
}
}
}
}
*/
}
}