From 6c8f5c44f7002e77a41d8c6ac96a2deef07003ea Mon Sep 17 00:00:00 2001 From: Nickiel12 <35903114+Nickiel12@users.noreply.github.com> Date: Sun, 2 Jan 2022 20:31:57 -0800 Subject: [PATCH] a bit of condensing --- src/main.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 96a6d5f..78a146d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,17 +40,12 @@ fn main() { match from_socket_rx.recv_timeout(Duration::from_millis(100)) { Ok(message) => { println!("main recieved: {}", message); - let json = serde_json::from_str(&message).unwrap(); - let update = StateUpdate::json_to_state_update(json); + let update = StateUpdate::json_to_state_update( + serde_json::from_str(&message).unwrap()); if update == StateUpdate::UpdateClient { update_all(&state, &socket); - } - let updates = state.handle_update(update, &hotkeys); - if updates.0.is_some() { - socket.send(updates.0.unwrap().to_json().to_string()); - } - if updates.1.is_some() { - handle_instructions(updates.1.unwrap(), &mut state, &socket, &hotkeys); + } else { + handle_instructions(vec![update], &mut state, &socket, &hotkeys); } }, Err(_) => {},