v0.15-WORKINGV4

This commit is contained in:
2022-12-04 13:26:08 +05:30
parent c8fba74480
commit e6c091dde0
2 changed files with 30 additions and 23 deletions

View File

@@ -327,6 +327,8 @@ async fn ListDB<G: Html>(cx: Scope<'_>) -> View<G> {
if *app_state.openlibrary.get() == false {
if *app_state.refreshing.get() == true {
info!("Refresh triggered");
app_state.books.set(Vec::new());
app_state.refreshing.set(false);
//TimeoutFuture::new(1000).await;
}
@@ -635,39 +637,42 @@ info!("Adding book");
time: Some(times),
isbn: Some(isbns),
};
if *app_state.adding.get() == true {
app_state.addingrequest.set(true);
} else if *app_state.updating.get() == true{
app_state.apibook.set(record);
app_state.addingbook.set(BookUI::default());
if *app_state.updating.get()==true {
app_state.updatingrequest.set(true);
}
app_state.apibook.set(record);
app_state.addingbook.set(BookUI::default());
if *app_state.adding.get()==true {
app_state.addingrequest.set(true);
}
app_state.updating.set(false);
app_state.adding.set(false);
//app_state.books.set(vec![BookUI::default()]);
};
create_effect(cx, || {
app_state.apibook.track();
let app_state = app_state.clone();
let record = (*app_state.apibook.get()).clone();
if *app_state.addingrequest.get() == true {
spawn_local(async move {
info!("Adding effect startedDone");
if *app_state.addingrequest.get() == true {
let temp = add_book(record).await.unwrap();
info!("Adding Done{}",temp.status());
app_state.refreshing.set(true);
app_state.addingrequest.set(false);
});
} else if *app_state.updatingrequest.get() == true{
spawn_local(async move {
} else if *app_state.updatingrequest.get() == true {
let temp = update_book(record).await.unwrap();
info!("Updating Done{}",temp.status());
app_state.refreshing.set(true);
app_state.updatingrequest.set(false);
});
}
});
});
create_effect(cx, || {