diff --git a/web/src/api.rs b/web/src/api.rs index 99fce6b..cd5d93f 100644 --- a/web/src/api.rs +++ b/web/src/api.rs @@ -328,12 +328,6 @@ impl HttpStore { } } - pub fn v1_path(&self) -> String { - let mut path = self.root.clone(); - path.push_str("/v1"); - path - } - pub fn v2_path(&self) -> String { let mut path = self.root.clone(); path.push_str("/v2"); @@ -352,7 +346,7 @@ impl HttpStore { #[instrument(skip_all, fields(?self, user))] pub async fn authenticate(&self, user: String, pass: String) -> Option { debug!("attempting login request against api."); - let mut path = self.v1_path(); + let mut path = self.v2_path(); path.push_str("/auth"); let result = reqwasm::http::Request::get(&path) .header( @@ -400,7 +394,7 @@ impl HttpStore { } //#[instrument] pub async fn get_categories(&self) -> Result, Error> { - let mut path = self.v1_path(); + let mut path = self.v2_path(); path.push_str("/categories"); let resp = match reqwasm::http::Request::get(&path).send().await { Ok(resp) => resp, @@ -426,7 +420,7 @@ impl HttpStore { #[instrument] pub async fn get_recipes(&self) -> Result>, Error> { - let mut path = self.v1_path(); + let mut path = self.v2_path(); path.push_str("/recipes"); let resp = match reqwasm::http::Request::get(&path).send().await { Ok(resp) => resp, @@ -455,7 +449,7 @@ impl HttpStore { &self, id: S, ) -> Result, Error> { - let mut path = self.v1_path(); + let mut path = self.v2_path(); path.push_str("/recipe/"); path.push_str(id.as_ref()); let resp = match reqwasm::http::Request::get(&path).send().await { @@ -490,7 +484,7 @@ impl HttpStore { #[instrument(skip(recipes), fields(count=recipes.len()))] pub async fn save_recipes(&self, recipes: Vec) -> Result<(), Error> { - let mut path = self.v1_path(); + let mut path = self.v2_path(); path.push_str("/recipes"); for r in recipes.iter() { if r.recipe_id().is_empty() { @@ -513,7 +507,7 @@ impl HttpStore { #[instrument(skip(categories))] pub async fn save_categories(&self, categories: String) -> Result<(), Error> { - let mut path = self.v1_path(); + let mut path = self.v2_path(); path.push_str("/categories"); let resp = reqwasm::http::Request::post(&path) .body(to_string(&categories).expect("Unable to encode categories as json")) @@ -550,7 +544,7 @@ impl HttpStore { } pub async fn save_plan(&self, plan: Vec<(String, i32)>) -> Result<(), Error> { - let mut path = self.v1_path(); + let mut path = self.v2_path(); path.push_str("/plan"); let resp = reqwasm::http::Request::post(&path) .body(to_string(&plan).expect("Unable to encode plan as json")) @@ -566,7 +560,7 @@ impl HttpStore { } pub async fn get_plan(&self) -> Result>, Error> { - let mut path = self.v1_path(); + let mut path = self.v2_path(); path.push_str("/plan"); let resp = reqwasm::http::Request::get(&path).send().await?; if resp.status() != 200 { @@ -582,7 +576,6 @@ impl HttpStore { } } - pub async fn get_inventory_data( &self, ) -> Result< ( diff --git a/web/src/app_state.rs b/web/src/app_state.rs index 7ce4ab6..1fb6cf2 100644 --- a/web/src/app_state.rs +++ b/web/src/app_state.rs @@ -153,7 +153,6 @@ impl StateMachine { ) -> Result<(), crate::api::Error> { let mut state = original.get().as_ref().clone(); info!("Synchronizing Recipes"); - let recipe_entries = &store.get_recipes().await?; let (staples, recipes) = filter_recipes(&recipe_entries)?; if let Some(recipes) = recipes { state.staples = staples; @@ -163,7 +162,6 @@ impl StateMachine { local_store.set_all_recipes(recipe_entries); } - let plan = store.get_plan().await?; if let Some(plan) = plan { // set the counts. let mut plan_map = BTreeMap::new(); @@ -186,7 +184,6 @@ impl StateMachine { .collect::>(); local_store.save_plan(&plan); info!("Checking for user account data"); - if let Some(user_data) = store.get_user_data().await { debug!("Successfully got account data from server"); local_store.set_user_data(Some(&user_data)); state.auth = Some(user_data); @@ -196,7 +193,6 @@ impl StateMachine { state.auth = user_data; } info!("Synchronizing categories"); - match store.get_categories().await { Ok(Some(categories_content)) => { debug!(categories=?categories_content); local_store.set_categories(Some(&categories_content)); @@ -211,7 +207,6 @@ impl StateMachine { } } info!("Synchronizing inventory data"); - match store.get_inventory_data().await { Ok((filtered_ingredients, modified_amts, extra_items)) => { local_store.set_inventory_data(( &filtered_ingredients,