mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-25 20:09:48 -04:00
Appservice conversion for sycamore 0.8
This commit is contained in:
parent
8c5093d77f
commit
9cf6bcc7fc
@ -20,7 +20,6 @@ pub enum AppRoutes {
|
|||||||
Recipe(String),
|
Recipe(String),
|
||||||
Categories,
|
Categories,
|
||||||
Login,
|
Login,
|
||||||
Error(String),
|
|
||||||
NotFound,
|
NotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ use tracing::{error, instrument};
|
|||||||
use crate::components::recipe_selection::*;
|
use crate::components::recipe_selection::*;
|
||||||
use crate::service::*;
|
use crate::service::*;
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
#[instrument]
|
#[instrument]
|
||||||
pub fn RecipeSelector<G: Html>(cx: Scope) -> View<G> {
|
pub fn RecipeSelector<G: Html>(cx: Scope) -> View<G> {
|
||||||
let app_service = get_appservice_from_context(cx).clone();
|
let app_service = get_appservice_from_context(cx).clone();
|
||||||
|
@ -24,7 +24,3 @@ pub use inventory::*;
|
|||||||
pub use login::*;
|
pub use login::*;
|
||||||
pub use plan::*;
|
pub use plan::*;
|
||||||
pub use recipe::*;
|
pub use recipe::*;
|
||||||
|
|
||||||
pub struct PageProps {
|
|
||||||
service: crate::service::AppService,
|
|
||||||
}
|
|
||||||
|
@ -164,28 +164,6 @@ impl AppService {
|
|||||||
.map_err(|e| format!("{:?}", e))
|
.map_err(|e| format!("{:?}", e))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(self))]
|
|
||||||
pub fn fetch_categories_from_storage(
|
|
||||||
&self,
|
|
||||||
) -> Result<Option<BTreeMap<String, String>>, String> {
|
|
||||||
match self.get_category_text()? {
|
|
||||||
Some(s) => {
|
|
||||||
let parsed = from_str::<String>(&s).map_err(|e| format!("{}", e))?;
|
|
||||||
if parsed.is_empty() {
|
|
||||||
return Ok(None);
|
|
||||||
}
|
|
||||||
match parse::as_categories(&parsed) {
|
|
||||||
Ok(categories) => Ok(Some(categories)),
|
|
||||||
Err(e) => {
|
|
||||||
debug!("Error parsing categories {}", e);
|
|
||||||
Err(format!("Error parsing categories {}", e))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => Ok(None),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[instrument(skip(self))]
|
#[instrument(skip(self))]
|
||||||
pub fn fetch_recipes_from_storage(
|
pub fn fetch_recipes_from_storage(
|
||||||
&self,
|
&self,
|
||||||
@ -236,16 +214,6 @@ impl AppService {
|
|||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_recipes(
|
|
||||||
&self,
|
|
||||||
) -> Result<(Option<Recipe>, Option<BTreeMap<String, Recipe>>), String> {
|
|
||||||
Ok(self.fetch_recipes_from_storage()?)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn fetch_categories(&self) -> Result<Option<BTreeMap<String, String>>, String> {
|
|
||||||
Ok(self.fetch_categories_from_storage()?)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn save_recipes(&self, recipes: Vec<RecipeEntry>) -> Result<(), String> {
|
pub async fn save_recipes(&self, recipes: Vec<RecipeEntry>) -> Result<(), String> {
|
||||||
self.store.save_recipes(recipes).await?;
|
self.store.save_recipes(recipes).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -50,12 +50,6 @@ fn route_switch<G: Html>(cx: Scope, route: &ReadSignal<AppRoutes>) -> View<G> {
|
|||||||
// TODO(Create a real one)
|
// TODO(Create a real one)
|
||||||
PlanPage()
|
PlanPage()
|
||||||
},
|
},
|
||||||
AppRoutes::Error(ref e) => {
|
|
||||||
let e = e.clone();
|
|
||||||
view! {cx,
|
|
||||||
"Error: " (e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user