refactor: input m_button

replace is_some() with a if let Some(), and improve comments
This commit is contained in:
Jack Wills
2022-05-30 00:44:40 +00:00
parent ad43f69152
commit fc39aea582
+7 -2
View File
@@ -101,9 +101,14 @@ impl InputHandler {
let gui_state = Arc::clone(&self.gui_state); let gui_state = Arc::clone(&self.gui_state);
if self.info_sleep.is_some() { // If the info box sleep handle is currently being executed, as in m is pressed twice within a 4000ms window
self.info_sleep.as_ref().unwrap().abort() // then cancel the first handle, as a new handle will be invoked
if let Some(info_sleep_timer) = self.info_sleep.as_ref() {
info_sleep_timer.abort();
} }
// Some(self.info_sleep).as_ref().unwrap().ab
self.info_sleep = Some(tokio::spawn(async move { self.info_sleep = Some(tokio::spawn(async move {
tokio::time::sleep(std::time::Duration::from_millis(4000)).await; tokio::time::sleep(std::time::Duration::from_millis(4000)).await;
gui_state.lock().reset_info_box() gui_state.lock().reset_info_box()