mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-22 19:40:14 -04:00
API naming consistency save_ -> store_
This commit is contained in:
parent
30293878fc
commit
96b03cb14a
@ -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<RecipeEntry>) -> Result<(), Error> {
|
||||
pub async fn store_recipes(&self, recipes: Vec<RecipeEntry>) -> 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<IngredientKey>,
|
||||
modified_amts: BTreeMap<IngredientKey, String>,
|
||||
|
@ -184,7 +184,7 @@ impl StateMachine {
|
||||
.iter()
|
||||
.map(|(k, v)| (k.clone(), *v as i32))
|
||||
.collect::<Vec<(String, i32)>>();
|
||||
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<Message, AppState> 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<Message, AppState> 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<Message, AppState> 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<Message, AppState> 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<Message, AppState> 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());
|
||||
|
@ -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(),
|
||||
)])
|
||||
|
Loading…
x
Reference in New Issue
Block a user