Skip to content

Commit

Permalink
set version, input, etc. correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj committed Jan 7, 2024
1 parent a3db6ae commit ed82ce3
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions router/src/components/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,16 @@ where
let form =
form_from_event(&ev).expect("couldn't find form submitter");
let form_data = FormData::new_with_form(&form).unwrap();
match ServFn::from_form_data(&form_data) {
Ok(new_input) => {
input.try_set(Some(new_input));
}
Err(err) => {
if let Some(error) = error {
error.set(Some(Box::new(err)));
}
}
}
let req = <<ServFn::Client as Client<ServFn::Error>>::Request as ClientReq<
ServFn::Error,
>>::try_new_post_form_data(
Expand All @@ -519,33 +529,30 @@ where
);
match req {
Ok(req) => {
action.set_pending(true);
spawn_local(async move {
// TODO set input
// TODO check order of setting things here, and use batch as needed
// TODO set version?
match <ServFn as ServerFn>::run_on_client_with_req(
let res = <ServFn as ServerFn>::run_on_client_with_req(
req,
redirect_hook.as_ref(),
)
.await
{
Ok(res) => {
batch(move || {
version.update(|n| *n += 1);
.await;
batch(move || {
version.update(|n| *n += 1);
action.set_pending(false);
match res {
Ok(res) => {
value.try_set(Some(Ok(res)));
});
}
Err(err) => {
batch(move || {
}
Err(err) => {
value.set(Some(Err(err.clone())));
if let Some(error) = error {
error.set(Some(Box::new(
ServerFnErrorErr::from(err),
)));
}
});
}
}
}
});
});
}
Err(_) => todo!(),
Expand Down

0 comments on commit ed82ce3

Please sign in to comment.