diff --git a/web/src/components/recipe.rs b/web/src/components/recipe.rs index 55f98a8..0fdea98 100644 --- a/web/src/components/recipe.rs +++ b/web/src/components/recipe.rs @@ -164,7 +164,7 @@ pub fn Viewer<'ctx, G: Html>(cx: Scope<'ctx>, props: RecipeComponentProps<'ctx>) let RecipeComponentProps { recipe_id, sh } = props; let state = app_state::State::get_from_context(cx); let view = create_signal(cx, View::empty()); - let recipe_signal = sh.get_selector(cx, |state| { + let recipe_signal = sh.get_selector(cx, move |state| { if let Some(recipe) = state.get().recipes.get(&recipe_id) { let title = recipe.title.clone(); let desc = recipe.desc.clone().unwrap_or_else(|| String::new()); diff --git a/web/src/components/recipe_list.rs b/web/src/components/recipe_list.rs index 3cc3ffe..062c828 100644 --- a/web/src/components/recipe_list.rs +++ b/web/src/components/recipe_list.rs @@ -11,14 +11,17 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -use crate::{app_state, components::recipe::Viewer}; +use crate::{ + app_state::{self, StateHandler}, + components::recipe::Viewer, +}; use sycamore::prelude::*; use tracing::{debug, instrument}; -#[instrument] +#[instrument(skip_all)] #[component] -pub fn RecipeList(cx: Scope) -> View { +pub fn RecipeList<'ctx, G: Html>(cx: Scope<'ctx>, sh: StateHandler<'ctx>) -> View { let state = app_state::State::get_from_context(cx); let menu_list = create_memo(cx, move || state.get_menu_list()); view! {cx, @@ -26,10 +29,10 @@ pub fn RecipeList(cx: Scope) -> View { div() { Indexed( iterable=menu_list, - view= |cx, (id, _count)| { + view= move |cx, (id, _count)| { debug!(id=%id, "Rendering recipe"); view ! {cx, - Viewer(id) + Viewer(recipe_id=id, sh=sh) hr() } } diff --git a/web/src/pages/planning/cook.rs b/web/src/pages/planning/cook.rs index 7779912..2ae3cf9 100644 --- a/web/src/pages/planning/cook.rs +++ b/web/src/pages/planning/cook.rs @@ -21,6 +21,6 @@ pub fn CookPage<'ctx, G: Html>(cx: Scope<'ctx>, sh: StateHandler<'ctx>) -> View< view! {cx, PlanningPage( selected=Some("Cook".to_owned()), - ) { RecipeList() } + ) { RecipeList(sh) } } } diff --git a/web/src/pages/recipe/edit.rs b/web/src/pages/recipe/edit.rs index d3ca8e3..be2e8bf 100644 --- a/web/src/pages/recipe/edit.rs +++ b/web/src/pages/recipe/edit.rs @@ -19,7 +19,7 @@ use tracing::instrument; #[instrument(skip_all, fields(recipe=props.recipe))] #[component()] -pub fn RecipeEditPage(cx: Scope, props: RecipePageProps) -> View { +pub fn RecipeEditPage<'ctx, G: Html>(cx: Scope<'ctx>, props: RecipePageProps<'ctx>) -> View { let RecipePageProps { recipe, sh } = props; view! {cx, RecipePage( diff --git a/web/src/pages/recipe/view.rs b/web/src/pages/recipe/view.rs index 2ff892b..54ef784 100644 --- a/web/src/pages/recipe/view.rs +++ b/web/src/pages/recipe/view.rs @@ -20,7 +20,7 @@ use super::{RecipePage, RecipePageProps}; #[instrument(skip_all, fields(recipe=props.recipe))] #[component()] -pub fn RecipeViewPage(cx: Scope, props: RecipePageProps) -> View { +pub fn RecipeViewPage<'ctx, G: Html>(cx: Scope<'ctx>, props: RecipePageProps<'ctx>) -> View { let RecipePageProps { recipe, sh } = props; view! {cx, RecipePage(