diff --git a/crates/ascend/src/pages/wall.rs b/crates/ascend/src/pages/wall.rs index 40aa34e..06889f8 100644 --- a/crates/ascend/src/pages/wall.rs +++ b/crates/ascend/src/pages/wall.rs @@ -70,6 +70,7 @@ pub fn Wall() -> impl IntoView { let wall = wall.await?; let problems = problems.await?; let user_interactions = user_interactions.await?; + let user_interactions = RwSignal::new(user_interactions); let v = view! { }; Ok::<_, ServerFnError>(v) })} @@ -92,7 +93,7 @@ fn WithProblem(#[prop(into)] problem: Signal) -> impl IntoView fn WithWall( #[prop(into)] wall: Signal, #[prop(into)] problems: Signal>, - #[prop(into)] user_interactions: Signal>, + #[prop(into)] user_interactions: RwSignal>, ) -> impl IntoView { tracing::trace!("Enter"); @@ -100,8 +101,21 @@ fn WithWall( let (problem_uid, set_problem_uid) = leptos_router::hooks::query_signal::("problem"); + let submit_attempt = ServerAction::>::new(); + Effect::new(move || { + if let Some(Ok(v)) = submit_attempt.value().get() { + let v = v.into_inner(); + user_interactions.update(|map| { + map.insert(v.problem_uid, v); + }); + } + }); + let submit_attempt_cb = StoredValue::new(move |attempt: server_functions::UpsertTodaysAttempt| { + submit_attempt.dispatch(RonEncoded(attempt)); + }); + let problem = signals::problem(problems, problem_uid.into()); - let user_interaction = signals::user_interaction(user_interactions, problem_uid.into()); + let user_interaction = signals::user_interaction(user_interactions.into(), problem_uid.into()); // Filter let (filter_holds, set_filter_holds) = signal(BTreeSet::new()); @@ -154,16 +168,9 @@ fn WithWall( }); }; - let grid = view! { - - {move || { - Suspend::new(async move { - tracing::debug!("executing grid suspend"); - let view = view! { }; - Ok::<_, ServerFnError>(view) - }) - }} - + let grid = move || { + let wall = wall.get(); + view! { } }; let filter = move || { @@ -295,7 +302,14 @@ fn WithWall( let Some(problem_uid) = problem_uid.get() else { return view! {}.into_any(); }; - view! { } + view! { + + } .into_any() }} @@ -309,39 +323,22 @@ fn WithUserInteraction( #[prop(into)] wall_uid: Signal, #[prop(into)] problem_uid: Signal, #[prop(into)] user_interaction: Signal>, + submit_attempt: StoredValue, ) -> impl IntoView { tracing::debug!("Enter WithUserInteraction"); - let parent_user_interaction = user_interaction; - - let user_interaction = RwSignal::new(None); - Effect::new(move || { - let i = parent_user_interaction.get(); - tracing::info!("setting user interaction to parent user interaction value: {i:?}"); - user_interaction.set(i); - }); - - let submit_attempt = ServerAction::>::new(); - let submit_attempt_value = submit_attempt.value(); - Effect::new(move || { - if let Some(Ok(v)) = submit_attempt_value.get() { - tracing::info!("setting user interaction to action return value: {v:?}"); - user_interaction.set(Some(v.into_inner())); - } - }); - - let todays_attempt = signals::todays_attempt(user_interaction.into()); + let todays_attempt = signals::todays_attempt(user_interaction); let mut attempt_radio_buttons = vec![]; for variant in [models::Attempt::Flash, models::Attempt::Send, models::Attempt::Attempt] { let ui_toggle = Signal::derive(move || todays_attempt.get() == Some(variant)); let onclick = move |_| { let attempt = if ui_toggle.get() { None } else { Some(variant) }; - submit_attempt.dispatch(RonEncoded(server_functions::UpsertTodaysAttempt { + submit_attempt.read_value()(server_functions::UpsertTodaysAttempt { wall_uid: wall_uid.get(), problem_uid: problem_uid.get(), attempt, - })); + }); }; attempt_radio_buttons.push(view! { }); }