Appservice conversion for sycamore 0.8

This commit is contained in:
Jeremy Wall 2022-10-10 20:49:18 -04:00
parent 8c5093d77f
commit 9cf6bcc7fc
5 changed files with 1 additions and 43 deletions

View File

@ -20,7 +20,6 @@ pub enum AppRoutes {
Recipe(String),
Categories,
Login,
Error(String),
NotFound,
}

View File

@ -18,6 +18,7 @@ use tracing::{error, instrument};
use crate::components::recipe_selection::*;
use crate::service::*;
#[allow(non_snake_case)]
#[instrument]
pub fn RecipeSelector<G: Html>(cx: Scope) -> View<G> {
let app_service = get_appservice_from_context(cx).clone();

View File

@ -24,7 +24,3 @@ pub use inventory::*;
pub use login::*;
pub use plan::*;
pub use recipe::*;
pub struct PageProps {
service: crate::service::AppService,
}

View File

@ -164,28 +164,6 @@ impl AppService {
.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))]
pub fn fetch_recipes_from_storage(
&self,
@ -236,16 +214,6 @@ impl AppService {
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> {
self.store.save_recipes(recipes).await?;
Ok(())

View File

@ -50,12 +50,6 @@ fn route_switch<G: Html>(cx: Scope, route: &ReadSignal<AppRoutes>) -> View<G> {
// TODO(Create a real one)
PlanPage()
},
AppRoutes::Error(ref e) => {
let e = e.clone();
view! {cx,
"Error: " (e)
}
}
}
}