maint: Cleanup a bunch of stuff

:wq
This commit is contained in:
Jeremy Wall 2023-11-25 22:07:39 -05:00
parent e6b827ca21
commit a399858728
4 changed files with 2 additions and 39 deletions

View File

@ -28,7 +28,6 @@ use wasm_bindgen::throw_str;
use crate::{
api::{HttpStore, LocalStore},
components,
linear::LinearSignal,
};
@ -355,9 +354,7 @@ impl MessageMapper<Message, AppState> for StateMachine {
// FIXME(jwall): We should have a global way to trigger error messages
error!(err=?e, "Unable to save Recipe");
// FIXME(jwall): This should be an error message
components::toast::error_message(cx, "Failed to save Recipe", None);
} else {
components::toast::message(cx, "Saved Recipe", None);
}
callback.map(|f| f());
});
@ -370,9 +367,6 @@ impl MessageMapper<Message, AppState> for StateMachine {
spawn_local_scoped(cx, async move {
if let Err(err) = store.delete_recipe(&recipe).await {
error!(?err, "Failed to delete recipe");
components::toast::error_message(cx, "Unable to delete recipe", None);
} else {
components::toast::message(cx, "Deleted Recipe", None);
}
callback.map(|f| f());
});
@ -393,7 +387,6 @@ impl MessageMapper<Message, AppState> for StateMachine {
original_copy.filtered_ingredients = BTreeSet::new();
original_copy.modified_amts = BTreeMap::new();
original_copy.extras = Vec::new();
components::toast::message(cx, "Reset Inventory", None);
}
Message::AddFilteredIngredient(key) => {
original_copy.filtered_ingredients.insert(key);
@ -422,9 +415,6 @@ impl MessageMapper<Message, AppState> for StateMachine {
);
if let Err(e) = store.store_app_state(&original_copy).await {
error!(err=?e, "Error saving app state");
components::toast::error_message(cx, "Failed to save user state", None);
} else {
components::toast::message(cx, "Saved user state", None);
};
local_store.store_app_state(&original_copy);
original.set(original_copy);
@ -441,9 +431,6 @@ impl MessageMapper<Message, AppState> for StateMachine {
spawn_local_scoped(cx, async move {
if let Err(err) = Self::load_state(&store, &local_store, original).await {
error!(?err, "Failed to load user state");
components::toast::error_message(cx, "Failed to load_state.", None);
} else {
components::toast::message(cx, "Loaded user state", None);
}
f.map(|f| f());
});
@ -454,9 +441,7 @@ impl MessageMapper<Message, AppState> for StateMachine {
spawn_local_scoped(cx, async move {
if let Err(err) = store.store_staples(content).await {
error!(?err, "Failed to store staples");
components::toast::error_message(cx, "Failed to store staples", None);
} else {
components::toast::message(cx, "Updated staples", None);
callback.map(|f| f());
}
});
@ -507,11 +492,6 @@ impl MessageMapper<Message, AppState> for StateMachine {
let local_store = self.local_store.clone();
spawn_local_scoped(cx, async move {
if let Err(err) = store.delete_plan_for_date(&date).await {
components::toast::error_message(
cx,
"Failed to delete meal plan for date",
None,
);
error!(?err, "Error deleting plan");
} else {
original_copy.plan_dates.remove(&date);
@ -522,7 +502,6 @@ impl MessageMapper<Message, AppState> for StateMachine {
original_copy.extras = Vec::new();
local_store.store_app_state(&original_copy);
original.set(original_copy);
components::toast::message(cx, "Deleted Plan", None);
callback.map(|f| f());
}

View File

@ -24,7 +24,6 @@ pub mod recipe_selection;
pub mod shopping_list;
pub mod staples;
pub mod tabs;
pub mod toast;
pub use add_recipe::*;
pub use categories::*;

View File

@ -13,8 +13,7 @@
// limitations under the License.
use js_sys::Date;
use tracing::error;
use wasm_bindgen::JsCast;
use web_sys::{window, Element, Storage, Window};
use web_sys::{window, Storage, Window};
pub fn get_storage() -> Storage {
get_window().local_storage()
@ -31,19 +30,6 @@ pub fn get_window() -> Window {
.expect("No window present")
}
pub fn get_element_by_id<E>(id: &str) -> Result<Option<E>, Element>
where
E: JsCast,
{
match get_window().document()
.expect("No document in window")
.get_element_by_id(id)
{
Some(e) => e.dyn_into::<E>().map(|e| Some(e)),
None => Ok(None),
}
}
pub trait LogFailures<V, E> {
fn swallow_and_log(self);
}

View File

@ -14,7 +14,7 @@
use crate::{
app_state::StateHandler,
components::{toast::Container, Footer, Header},
components::{Footer, Header},
pages::*,
};
use sycamore::prelude::*;
@ -137,7 +137,6 @@ pub fn Handler<'ctx, G: Html>(cx: Scope<'ctx>, props: HandlerProps<'ctx>) -> Vie
view=move |cx: Scope, route: &ReadSignal<Routes>| {
view!{cx,
div(class="app") {
Container()
Header(sh)
(route_switch(route.get().as_ref(), cx, sh))
Footer { }