fix: resolve clippy warnings in iced client

This commit is contained in:
ReTeamSpeak
2026-05-13 16:06:04 +09:00
parent 358aaa2ea5
commit 43967cf309
3 changed files with 25 additions and 33 deletions
+13 -16
View File
@@ -605,7 +605,7 @@ impl App {
let _ = handle let _ = handle
.with_connection(move |con| -> Result<(), String> { .with_connection(move |con| -> Result<(), String> {
let state = con.get_state().map_err(|e| e.to_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() let cmd = state.client_update()
.set_input_muted(muted); .set_input_muted(muted);
cmd.send(con).map_err(|e| e.to_string())?; cmd.send(con).map_err(|e| e.to_string())?;
@@ -629,7 +629,7 @@ impl App {
let _ = handle let _ = handle
.with_connection(move |con| -> Result<(), String> { .with_connection(move |con| -> Result<(), String> {
let state = con.get_state().map_err(|e| e.to_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() let cmd = state.client_update()
.set_output_muted(muted); .set_output_muted(muted);
cmd.send(con).map_err(|e| e.to_string())?; cmd.send(con).map_err(|e| e.to_string())?;
@@ -653,7 +653,7 @@ impl App {
let _ = handle let _ = handle
.with_connection(move |con| -> Result<(), String> { .with_connection(move |con| -> Result<(), String> {
let state = con.get_state().map_err(|e| e.to_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() let cmd = state.client_update()
.set_output_hardware_enabled(!muted); .set_output_hardware_enabled(!muted);
cmd.send(con).map_err(|e| e.to_string())?; cmd.send(con).map_err(|e| e.to_string())?;
@@ -677,7 +677,7 @@ impl App {
let _ = handle let _ = handle
.with_connection(move |con| -> Result<(), String> { .with_connection(move |con| -> Result<(), String> {
let state = con.get_state().map_err(|e| e.to_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 { let cmd = if afk {
state.client_update() state.client_update()
.set_input_muted(true) .set_input_muted(true)
@@ -909,20 +909,22 @@ impl App {
// Keyboard events for PTT // Keyboard events for PTT
subs.push(iced::event::listen().map(|event| { subs.push(iced::event::listen().map(|event| {
match event { match event {
iced::Event::Keyboard(iced::keyboard::Event::KeyPressed { ref key, .. }) => { iced::Event::Keyboard(iced::keyboard::Event::KeyPressed {
if let iced::keyboard::Key::Character(c) = key { key: iced::keyboard::Key::Character(c),
..
}) => {
if c.as_str().to_lowercase() == "v" { if c.as_str().to_lowercase() == "v" {
return Message::PttPressed; return Message::PttPressed;
} }
} }
} iced::Event::Keyboard(iced::keyboard::Event::KeyReleased {
iced::Event::Keyboard(iced::keyboard::Event::KeyReleased { ref key, .. }) => { key: iced::keyboard::Key::Character(c),
if let iced::keyboard::Key::Character(c) = key { ..
}) => {
if c.as_str().to_lowercase() == "v" { if c.as_str().to_lowercase() == "v" {
return Message::PttReleased; return Message::PttReleased;
} }
} }
}
_ => {} _ => {}
} }
Message::Noop Message::Noop
@@ -972,16 +974,11 @@ impl App {
return; return;
} }
} }
loop { while let Ok(samples) = sample_rx.recv() {
match sample_rx.recv() {
Ok(samples) => {
if sender.send(Message::MicSamples(samples)).await.is_err() { if sender.send(Message::MicSamples(samples)).await.is_err() {
break; break;
} }
} }
Err(_) => break,
}
}
let mut mic_guard = mic.lock().await; let mut mic_guard = mic.lock().await;
mic_guard.stop(); mic_guard.stop();
}), }),
+1 -6
View File
@@ -88,17 +88,12 @@ pub fn start_transmission(
} }
}); });
loop { while let Ok(samples) = sample_rx.recv() {
match sample_rx.recv() {
Ok(samples) => {
let mut nr = noise_reducer.lock().await; let mut nr = noise_reducer.lock().await;
let mut samples_copy = samples.clone(); let mut samples_copy = samples.clone();
nr.process(&mut samples_copy); nr.process(&mut samples_copy);
enc.encode_and_send(&samples_copy, &audio_tx); enc.encode_and_send(&samples_copy, &audio_tx);
} }
Err(_) => break,
}
}
let mut mic_guard = mic.lock().await; let mut mic_guard = mic.lock().await;
mic_guard.stop(); mic_guard.stop();
+1 -1
View File
@@ -855,7 +855,7 @@ impl App {
pub(crate) fn recent_bookmarks(&self, limit: usize) -> Vec<&BookmarkInfo> { pub(crate) fn recent_bookmarks(&self, limit: usize) -> Vec<&BookmarkInfo> {
let mut bookmarks: Vec<&BookmarkInfo> = self.bookmarks.iter().collect(); 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 bookmarks
.into_iter() .into_iter()
.filter(|bookmark| bookmark.last_used_at.is_some()) .filter(|bookmark| bookmark.last_used_at.is_some())