From fdaf5ad70dd79d65e42f604e5ce7ce43121c9e8d Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Wed, 28 Dec 2022 19:27:14 -0600 Subject: [PATCH] Use a state handler selector for RecipeList --- web/src/components/recipe_list.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/web/src/components/recipe_list.rs b/web/src/components/recipe_list.rs index 062c828..787bd01 100644 --- a/web/src/components/recipe_list.rs +++ b/web/src/components/recipe_list.rs @@ -11,10 +11,7 @@ // 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::{self, StateHandler}, - components::recipe::Viewer, -}; +use crate::{app_state::StateHandler, components::recipe::Viewer}; use sycamore::prelude::*; use tracing::{debug, instrument}; @@ -22,8 +19,15 @@ use tracing::{debug, instrument}; #[instrument(skip_all)] #[component] 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()); + let menu_list = sh.get_selector(cx, |state| { + state + .get() + .recipe_counts + .iter() + .map(|(k, v)| (k.clone(), v.clone())) + .filter(|(_, v)| *(v) != 0) + .collect() + }); view! {cx, h1 { "Recipe List" } div() {