diff --git a/src/iced-app/src/main.rs b/src/iced-app/src/main.rs index 95358c4..6fff4b5 100644 --- a/src/iced-app/src/main.rs +++ b/src/iced-app/src/main.rs @@ -605,7 +605,7 @@ impl App { let _ = handle .with_connection(move |con| -> Result<(), String> { let state = con.get_state().map_err(|e| e.to_string())?; - if state.clients.get(&state.own_client).is_some() { + if state.clients.contains_key(&state.own_client) { let cmd = state.client_update() .set_input_muted(muted); cmd.send(con).map_err(|e| e.to_string())?; @@ -629,7 +629,7 @@ impl App { let _ = handle .with_connection(move |con| -> Result<(), String> { let state = con.get_state().map_err(|e| e.to_string())?; - if state.clients.get(&state.own_client).is_some() { + if state.clients.contains_key(&state.own_client) { let cmd = state.client_update() .set_output_muted(muted); cmd.send(con).map_err(|e| e.to_string())?; @@ -653,7 +653,7 @@ impl App { let _ = handle .with_connection(move |con| -> Result<(), String> { let state = con.get_state().map_err(|e| e.to_string())?; - if state.clients.get(&state.own_client).is_some() { + if state.clients.contains_key(&state.own_client) { let cmd = state.client_update() .set_output_hardware_enabled(!muted); cmd.send(con).map_err(|e| e.to_string())?; @@ -677,7 +677,7 @@ impl App { let _ = handle .with_connection(move |con| -> Result<(), String> { let state = con.get_state().map_err(|e| e.to_string())?; - if state.clients.get(&state.own_client).is_some() { + if state.clients.contains_key(&state.own_client) { let cmd = if afk { state.client_update() .set_input_muted(true) @@ -909,18 +909,20 @@ impl App { // Keyboard events for PTT subs.push(iced::event::listen().map(|event| { match event { - iced::Event::Keyboard(iced::keyboard::Event::KeyPressed { ref key, .. }) => { - if let iced::keyboard::Key::Character(c) = key { - if c.as_str().to_lowercase() == "v" { - return Message::PttPressed; - } + iced::Event::Keyboard(iced::keyboard::Event::KeyPressed { + key: iced::keyboard::Key::Character(c), + .. + }) => { + if c.as_str().to_lowercase() == "v" { + return Message::PttPressed; } } - iced::Event::Keyboard(iced::keyboard::Event::KeyReleased { ref key, .. }) => { - if let iced::keyboard::Key::Character(c) = key { - if c.as_str().to_lowercase() == "v" { - return Message::PttReleased; - } + iced::Event::Keyboard(iced::keyboard::Event::KeyReleased { + key: iced::keyboard::Key::Character(c), + .. + }) => { + if c.as_str().to_lowercase() == "v" { + return Message::PttReleased; } } _ => {} @@ -972,14 +974,9 @@ impl App { return; } } - loop { - match sample_rx.recv() { - Ok(samples) => { - if sender.send(Message::MicSamples(samples)).await.is_err() { - break; - } - } - Err(_) => break, + while let Ok(samples) = sample_rx.recv() { + if sender.send(Message::MicSamples(samples)).await.is_err() { + break; } } let mut mic_guard = mic.lock().await; diff --git a/src/iced-app/src/runtime.rs b/src/iced-app/src/runtime.rs index 7c88788..9d1de29 100644 --- a/src/iced-app/src/runtime.rs +++ b/src/iced-app/src/runtime.rs @@ -88,16 +88,11 @@ pub fn start_transmission( } }); - loop { - match sample_rx.recv() { - Ok(samples) => { - let mut nr = noise_reducer.lock().await; - let mut samples_copy = samples.clone(); - nr.process(&mut samples_copy); - enc.encode_and_send(&samples_copy, &audio_tx); - } - Err(_) => break, - } + while let Ok(samples) = sample_rx.recv() { + let mut nr = noise_reducer.lock().await; + let mut samples_copy = samples.clone(); + nr.process(&mut samples_copy); + enc.encode_and_send(&samples_copy, &audio_tx); } let mut mic_guard = mic.lock().await; diff --git a/src/iced-app/src/view.rs b/src/iced-app/src/view.rs index 3ca65ef..baa6755 100644 --- a/src/iced-app/src/view.rs +++ b/src/iced-app/src/view.rs @@ -855,7 +855,7 @@ impl App { pub(crate) fn recent_bookmarks(&self, limit: usize) -> Vec<&BookmarkInfo> { let mut bookmarks: Vec<&BookmarkInfo> = self.bookmarks.iter().collect(); - bookmarks.sort_by(|a, b| b.last_used_at.cmp(&a.last_used_at)); + bookmarks.sort_by_key(|bookmark| std::cmp::Reverse(bookmark.last_used_at)); bookmarks .into_iter() .filter(|bookmark| bookmark.last_used_at.is_some())