From 96b03cb14abe050881ce64d5671284d74c67c930 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Thu, 5 Jan 2023 13:06:19 -0500 Subject: [PATCH] API naming consistency save_ -> store_ --- web/src/api.rs | 16 ++++++++-------- web/src/app_state.rs | 12 ++++++------ web/src/components/recipe.rs | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/web/src/api.rs b/web/src/api.rs index 640a4b1..3145067 100644 --- a/web/src/api.rs +++ b/web/src/api.rs @@ -244,7 +244,7 @@ impl LocalStore { } /// Save working plan to local storage. - pub fn save_plan(&self, plan: &Vec<(String, i32)>) { + pub fn store_plan(&self, plan: &Vec<(String, i32)>) { self.store .set("plan", &to_string(&plan).expect("Failed to serialize plan")) .expect("Failed to store plan'"); @@ -483,7 +483,7 @@ impl HttpStore { } #[instrument(skip(recipes), fields(count=recipes.len()))] - pub async fn save_recipes(&self, recipes: Vec) -> Result<(), Error> { + pub async fn store_recipes(&self, recipes: Vec) -> Result<(), Error> { let mut path = self.v2_path(); path.push_str("/recipes"); for r in recipes.iter() { @@ -506,7 +506,7 @@ impl HttpStore { } #[instrument(skip(categories))] - pub async fn save_categories(&self, categories: String) -> Result<(), Error> { + pub async fn store_categories(&self, categories: String) -> Result<(), Error> { let mut path = self.v2_path(); path.push_str("/categories"); let resp = reqwasm::http::Request::post(&path) @@ -523,15 +523,15 @@ impl HttpStore { } #[instrument(skip_all)] - pub async fn save_app_state(&self, state: AppState) -> Result<(), Error> { + pub async fn store_app_state(&self, state: AppState) -> Result<(), Error> { let mut plan = Vec::new(); for (key, count) in state.recipe_counts.iter() { plan.push((key.clone(), *count as i32)); } debug!("Saving plan data"); - self.save_plan(plan).await?; + self.store_plan(plan).await?; debug!("Saving inventory data"); - self.save_inventory_data( + self.store_inventory_data( state.filtered_ingredients, state.modified_amts, state @@ -543,7 +543,7 @@ impl HttpStore { .await } - pub async fn save_plan(&self, plan: Vec<(String, i32)>) -> Result<(), Error> { + pub async fn store_plan(&self, plan: Vec<(String, i32)>) -> Result<(), Error> { let mut path = self.v2_path(); path.push_str("/plan"); let resp = reqwasm::http::Request::post(&path) @@ -616,7 +616,7 @@ impl HttpStore { } #[instrument] - pub async fn save_inventory_data( + pub async fn store_inventory_data( &self, filtered_ingredients: BTreeSet, modified_amts: BTreeMap, diff --git a/web/src/app_state.rs b/web/src/app_state.rs index ecb784b..586ac13 100644 --- a/web/src/app_state.rs +++ b/web/src/app_state.rs @@ -184,7 +184,7 @@ impl StateMachine { .iter() .map(|(k, v)| (k.clone(), *v as i32)) .collect::>(); - local_store.save_plan(&plan); + local_store.store_plan(&plan); info!("Checking for user account data"); if let Some(user_data) = store.fetch_user_data().await { debug!("Successfully got account data from server"); @@ -244,7 +244,7 @@ impl MessageMapper for StateMachine { } let plan: Vec<(String, i32)> = map.iter().map(|(s, i)| (s.clone(), *i as i32)).collect(); - self.local_store.save_plan(&plan); + self.local_store.store_plan(&plan); original_copy.recipe_counts = map; } Message::UpdateRecipeCount(id, count) => { @@ -254,7 +254,7 @@ impl MessageMapper for StateMachine { .iter() .map(|(s, i)| (s.clone(), *i as i32)) .collect(); - self.local_store.save_plan(&plan); + self.local_store.store_plan(&plan); } Message::AddExtra(amt, name) => { original_copy.extras.push((amt, name)); @@ -303,7 +303,7 @@ impl MessageMapper for StateMachine { let store = self.store.clone(); self.local_store.set_recipe_entry(&entry); spawn_local_scoped(cx, async move { - if let Err(e) = store.save_recipes(vec![entry]).await { + if let Err(e) = store.store_recipes(vec![entry]).await { error!(err=?e, "Unable to save Recipe"); } }); @@ -313,7 +313,7 @@ impl MessageMapper for StateMachine { self.local_store.set_categories(Some(&category_text)); let store = self.store.clone(); spawn_local_scoped(cx, async move { - if let Err(e) = store.save_categories(category_text).await { + if let Err(e) = store.store_categories(category_text).await { error!(?e, "Failed to save categories"); } }); @@ -352,7 +352,7 @@ impl MessageMapper for StateMachine { let original_copy = original_copy.clone(); let store = self.store.clone(); spawn_local_scoped(cx, async move { - if let Err(e) = store.save_app_state(original_copy).await { + if let Err(e) = store.store_app_state(original_copy).await { error!(err=?e, "Error saving app state") }; f.map(|f| f()); diff --git a/web/src/components/recipe.rs b/web/src/components/recipe.rs index c124c0b..e642d41 100644 --- a/web/src/components/recipe.rs +++ b/web/src/components/recipe.rs @@ -95,7 +95,7 @@ pub fn Editor<'ctx, G: Html>(cx: Scope<'ctx>, props: RecipeComponentProps<'ctx>) async move { debug!("Attempting to save recipe"); if let Err(e) = store - .save_recipes(vec![RecipeEntry( + .store_recipes(vec![RecipeEntry( id.get_untracked().as_ref().clone(), text.get_untracked().as_ref().clone(), )])