From 92c533c735e4bb1c898285aeee7c65ef8789c408 Mon Sep 17 00:00:00 2001 From: pauldelucia Date: Wed, 8 Jan 2025 11:24:38 +0700 Subject: [PATCH 1/4] fix: broadcast transition button missing --- src/ui/tools/transition_visualizer_screen.rs | 66 ++++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/ui/tools/transition_visualizer_screen.rs b/src/ui/tools/transition_visualizer_screen.rs index ff72728..602d633 100644 --- a/src/ui/tools/transition_visualizer_screen.rs +++ b/src/ui/tools/transition_visualizer_screen.rs @@ -119,43 +119,43 @@ impl TransitionVisualizerScreen { ui.add_space(10.0); - // If we’re not done or not in the middle of broadcasting, we can show the button + // if we are NotStarted or in an Error state, show the button if matches!( self.broadcast_status, TransitionBroadcastStatus::NotStarted | TransitionBroadcastStatus::Error(_) ) { - if let TransitionBroadcastStatus::Submitting(_) = self.broadcast_status { - // Broadcast button - let mut new_style = (**ui.style()).clone(); - new_style.spacing.button_padding = egui::vec2(10.0, 5.0); - ui.set_style(new_style); - let button = egui::Button::new( - RichText::new("Broadcast Transition to Platform").color(Color32::WHITE), - ) - .fill(Color32::from_rgb(0, 128, 255)) - .frame(true) - .rounding(3.0); - if ui.add(button).clicked() { - // Mark as submitting - let now = SystemTime::now() - .duration_since(UNIX_EPOCH) - .expect("Time went backwards") - .as_secs(); - self.broadcast_status = TransitionBroadcastStatus::Submitting(now); - // Kick off the backend task - match StateTransition::deserialize_from_bytes( - &hex::decode(&self.input_data).unwrap(), - ) { - Ok(state_transition) => { - app_action = AppAction::BackendTask( - BackendTask::BroadcastStateTransition(state_transition), - ); - } - Err(e) => { - self.broadcast_status = TransitionBroadcastStatus::Error( - format!("Failed to parse state transition: {}", e), - ); - } + let mut new_style = (**ui.style()).clone(); + new_style.spacing.button_padding = egui::vec2(10.0, 5.0); + ui.set_style(new_style); + + let button = egui::Button::new( + RichText::new("Broadcast Transition to Platform").color(Color32::WHITE), + ) + .fill(Color32::from_rgb(0, 128, 255)) + .frame(true) + .rounding(3.0); + + if ui.add(button).clicked() { + // Mark as submitting + let now = SystemTime::now() + .duration_since(UNIX_EPOCH) + .expect("Time went backwards") + .as_secs(); + self.broadcast_status = TransitionBroadcastStatus::Submitting(now); + + match StateTransition::deserialize_from_bytes( + &hex::decode(&self.input_data).unwrap(), + ) { + Ok(state_transition) => { + app_action = AppAction::BackendTask( + BackendTask::BroadcastStateTransition(state_transition), + ); + } + Err(e) => { + self.broadcast_status = TransitionBroadcastStatus::Error(format!( + "Failed to parse state transition: {}", + e + )); } } } From 430a77c4883fe89886d95e7cc9d60774872ad120 Mon Sep 17 00:00:00 2001 From: pauldelucia Date: Wed, 8 Jan 2025 11:31:45 +0700 Subject: [PATCH 2/4] chore: bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 35898d4..fca9b67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dash-evo-tool" -version = "0.7.0" +version = "0.7.1" license = "MIT" edition = "2021" default-run = "dash-evo-tool" From 2c0100aed299622e70996fc2f5a2b1a324ec31a2 Mon Sep 17 00:00:00 2001 From: pauldelucia Date: Wed, 8 Jan 2025 11:39:18 +0700 Subject: [PATCH 3/4] fix: error message displaying even after input changes --- src/ui/tools/transition_visualizer_screen.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ui/tools/transition_visualizer_screen.rs b/src/ui/tools/transition_visualizer_screen.rs index 602d633..cac31f7 100644 --- a/src/ui/tools/transition_visualizer_screen.rs +++ b/src/ui/tools/transition_visualizer_screen.rs @@ -41,9 +41,13 @@ impl TransitionVisualizerScreen { } fn parse_input(&mut self) { - // Clear previous parse results, but let's not overwrite broadcast_status + // Clear previous parse results... self.parsed_json = None; + // Reset the broadcast status so we no longer show old errors + // or "Submitting" states from a previous parse/broadcast. + self.broadcast_status = TransitionBroadcastStatus::NotStarted; + // Try to decode the input as hex first let decoded_bytes = hex::decode(&self.input_data).or_else(|_| { STANDARD @@ -56,7 +60,7 @@ impl TransitionVisualizerScreen { // Try to deserialize into a StateTransition match StateTransition::deserialize_from_bytes(&bytes) { Ok(state_transition) => { - // Convert state transition to JSON + // Convert to JSON match serde_json::to_string_pretty(&state_transition) { Ok(json) => self.parsed_json = Some(json), Err(e) => { @@ -68,10 +72,8 @@ impl TransitionVisualizerScreen { } } Err(e) => { - self.broadcast_status = TransitionBroadcastStatus::Error(format!( - "Failed to parse state transition: {}", - e - )); + self.broadcast_status = + TransitionBroadcastStatus::Error(format!("Failed to parse: {}", e)); } } } From c71bd7fa375796b6f02c730d0d3478f17e3981e1 Mon Sep 17 00:00:00 2001 From: pauldelucia Date: Wed, 8 Jan 2025 12:07:33 +0700 Subject: [PATCH 4/4] fix: remove redundant decoding --- src/ui/tools/transition_visualizer_screen.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/ui/tools/transition_visualizer_screen.rs b/src/ui/tools/transition_visualizer_screen.rs index cac31f7..27c2d36 100644 --- a/src/ui/tools/transition_visualizer_screen.rs +++ b/src/ui/tools/transition_visualizer_screen.rs @@ -145,20 +145,12 @@ impl TransitionVisualizerScreen { .as_secs(); self.broadcast_status = TransitionBroadcastStatus::Submitting(now); - match StateTransition::deserialize_from_bytes( - &hex::decode(&self.input_data).unwrap(), - ) { - Ok(state_transition) => { + if let Some(json) = &self.parsed_json { + if let Ok(state_transition) = serde_json::from_str(json) { app_action = AppAction::BackendTask( BackendTask::BroadcastStateTransition(state_transition), ); } - Err(e) => { - self.broadcast_status = TransitionBroadcastStatus::Error(format!( - "Failed to parse state transition: {}", - e - )); - } } } }