From c25d7cf62d2d1be15b9bb4a2cf2c5de87fe2422c Mon Sep 17 00:00:00 2001 From: PetoMPP Date: Sat, 23 Dec 2023 11:07:19 +0100 Subject: [PATCH] #33: Add better state checks to prevent not needed requests --- src/components/organisms/editor/atoms/delete_button.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/organisms/editor/atoms/delete_button.rs b/src/components/organisms/editor/atoms/delete_button.rs index f987ead..27d6268 100644 --- a/src/components/organisms/editor/atoms/delete_button.rs +++ b/src/components/organisms/editor/atoms/delete_button.rs @@ -37,8 +37,13 @@ pub fn delete_button(props: &EditorProps) -> Html { let Some(resid) = &props.resid else { return; }; - if let EditorState::Loading = &props.state { - return; + match &props.state { + &EditorState::Ok(Some(_)) | &EditorState::Err(_) => return, + _ => {} + } + match &(*state) { + &State::Loading => return, + _ => {} } let resid = resid.clone(); state.set(State::Loading);