From 3f0836dad222a2d5fdac56cb2c833ad851cb85fd Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 17 Jan 2023 13:31:51 -0500 Subject: [PATCH] Load plan_dates during the load state phase --- web/src/app_state.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/src/app_state.rs b/web/src/app_state.rs index 0c7d6ea..f2df26e 100644 --- a/web/src/app_state.rs +++ b/web/src/app_state.rs @@ -16,6 +16,7 @@ use std::{ fmt::Debug, }; +use chrono::NaiveDate; use client_api::UserData; use recipes::{parse, Ingredient, IngredientKey, Recipe, RecipeEntry}; use sycamore::futures::spawn_local_scoped; @@ -36,6 +37,7 @@ pub struct AppState { pub filtered_ingredients: BTreeSet, pub modified_amts: BTreeMap, pub auth: Option, + pub plan_dates: BTreeSet, } impl AppState { @@ -49,6 +51,7 @@ impl AppState { filtered_ingredients: BTreeSet::new(), modified_amts: BTreeMap::new(), auth: None, + plan_dates: BTreeSet::new(), } } } @@ -180,6 +183,12 @@ impl StateMachine { local_store.set_all_recipes(recipe_entries); } + info!("Fetching meal plan list"); + let plan_dates = store.fetch_plan_dates().await?; + if let Some(mut plan_dates) = plan_dates { + debug!(?plan_dates, "meal plan list"); + state.plan_dates = BTreeSet::from_iter(plan_dates.drain(0..)); + } info!("Synchronizing meal plan"); let plan = store.fetch_plan().await?; if let Some(plan) = plan {